diff --git a/base/linalg/conjarray.jl b/base/linalg/conjarray.jl index 26501e8ee8741..436ffbf22ee84 100644 --- a/base/linalg/conjarray.jl +++ b/base/linalg/conjarray.jl @@ -15,7 +15,10 @@ end @inline ConjArray{T,N}(a::AbstractArray{T,N}) = ConjArray{conj_type(T), N, typeof(a)}(a) typealias ConjVector{T, V <: AbstractVector} ConjArray{T, 1, V} +@inline ConjVector{T}(v::AbstractVector{T}) = ConjArray{conj_type(T), 1, typeof(v)}(v) + typealias ConjMatrix{T, M <: AbstractMatrix} ConjArray{T, 2, M} +@inline ConjMatrix{T}(m::AbstractMatrix{T}) = ConjArray{conj_type(T), 2, typeof(m)}(m) # This type can cause the element type to change under conjugation - e.g. an array of complex arrays. @inline conj_type(x) = conj_type(typeof(x)) @@ -34,6 +37,8 @@ linearindexing{CA <: ConjArray}(::Type{CA}) = linearindexing(parent_type(CA)) @propagate_inbounds setindex!{T,N}(a::ConjArray{T,N}, v, i::Int) = setindex!(a.parent, conj(v), i) @propagate_inbounds setindex!{T,N}(a::ConjArray{T,N}, v, i::Vararg{Int,N}) = setindex!(a.parent, conj(v), i...) +# TODO similar + # Currently, this is default behavior for RowVector only """ conj(rowvector) diff --git a/base/linalg/rowvector.jl b/base/linalg/rowvector.jl index eb8e118919df6..630bc22c779f8 100644 --- a/base/linalg/rowvector.jl +++ b/base/linalg/rowvector.jl @@ -72,7 +72,8 @@ julia> transpose(v) @inline ctranspose{T<:Real}(vec::AbstractVector{T}) = RowVector(vec) @inline transpose(rowvec::RowVector) = rowvec.vec -@inline ctranspose{T}(rowvec::RowVector{T}) = _conj(rowvec.vec) +@inline transpose(rowvec::ConjRowVector) = copy(rowvec.vec) # remove the ConjArray wrapper from any raw vector +@inline ctranspose{T}(rowvec::RowVector{T}) = conj(rowvec.vec) @inline ctranspose{T<:Real}(rowvec::RowVector{T}) = rowvec.vec parent(rowvec::RowVector) = rowvec.vec diff --git a/test/linalg/conjarray.jl b/test/linalg/conjarray.jl index b446fb441e37b..b363037786a6f 100644 --- a/test/linalg/conjarray.jl +++ b/test/linalg/conjarray.jl @@ -18,6 +18,10 @@ end rv = v' @test (parent(rv) isa ConjArray) @test rv' === v + + # Currently, view behavior defaults to only RowVectors. + @test isa((v').', Vector) + @test isa((v.')', Vector) end end diff --git a/test/linalg/rowvector.jl b/test/linalg/rowvector.jl index 313c0318081e9..315ec12586f5d 100644 --- a/test/linalg/rowvector.jl +++ b/test/linalg/rowvector.jl @@ -25,7 +25,7 @@ @test (rv.')::Vector == [1, 2, 3] @test (rv')::Vector == [1, 2, 3] @test (tz.')::Vector == [1+im, 2, 3] - @test (tz')::ConjVector == [1-im, 2, 3] + @test (tz')::Vector == [1-im, 2, 3] @test conj(rv) === rv @test conj(tz) == [1-im 2 3]