diff --git a/base/deprecated.jl b/base/deprecated.jl index 028eb08361c710..ab85d4533af3ae 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -2540,6 +2540,27 @@ end @deprecate RowVector{T}(n::Tuple{Int,Int}) where {T} RowVector{T}(uninitialized, n) end +# deprecate adjoint(v)/tranpose(v) for v<:AbstractVector in favor of Adjoint/Transpose +@eval Base.LinAlg begin + @deprecate adjoint(sv::AbstractVector) Adjoint(sv) + @deprecate transpose(sv::AbstractVector) Transpose(sv) +end +@eval Base.SparseArrays begin + @deprecate adjoint(sv::SparseVector) Adjoint(sv) + @deprecate transpose(sv::SparseVector) Transpose(sv) +end +@eval Base.LinAlg begin + @deprecate adjoint(B::BitVector) Adjoint(B) +end +@eval Base.LinAlg begin + function adjoint(A::AbstractVector{<:Real}) + Base.depwarn(string("`adjoint(A::AbstractVector{<:Real})` yielding a ", + "`RowVector{eltype(A),typeof(A)}` has been deprecated in favor of Transpose(A) ", + "(or `Adjoint(A)`, depending on the existing code's intent)."), :adjoint) + return Transpose(A) + end +end + # A[ct]_(mul|ldiv|rdiv)_B[ct][!] methods from base/operators.jl, to deprecate @deprecate Ac_ldiv_Bt(a,b) (\)(Adjoint(a), Transpose(b)) @deprecate At_ldiv_Bt(a,b) (\)(Transpose(a), Transpose(b)) diff --git a/base/linalg/adjtrans.jl b/base/linalg/adjtrans.jl index 6d7b56aa89fe8b..682d2e5f35216c 100644 --- a/base/linalg/adjtrans.jl +++ b/base/linalg/adjtrans.jl @@ -64,10 +64,6 @@ transpose(A::Transpose) = copy(A.parent) adjoint(A::Transpose) = conj!(copy(A.parent)) transpose(A::Adjoint) = conj!(copy(A.parent)) -# lowercase quasi-constructors for vectors, TODO: deprecate -adjoint(sv::AbstractVector) = Adjoint(sv) -transpose(sv::AbstractVector) = Transpose(sv) - # some aliases for internal convenience use const AdjOrTrans{T,S} = Union{Adjoint{T,S},Transpose{T,S}} where {T,S} diff --git a/base/linalg/bitarray.jl b/base/linalg/bitarray.jl index d2f1601f418ff3..ba7d1985063ec2 100644 --- a/base/linalg/bitarray.jl +++ b/base/linalg/bitarray.jl @@ -284,4 +284,4 @@ function transpose(B::BitMatrix) return Bt end -adjoint(B::Union{BitMatrix,BitVector}) = transpose(B) +adjoint(B::BitMatrix) = transpose(B) diff --git a/base/linalg/transpose.jl b/base/linalg/transpose.jl index a6a8c1622a3780..4a4f7743767cc7 100644 --- a/base/linalg/transpose.jl +++ b/base/linalg/transpose.jl @@ -180,7 +180,6 @@ function adjoint(A::AbstractMatrix) adjoint!(B, A) end -@inline adjoint(A::AbstractVector{<:Real}) = transpose(A) @inline adjoint(A::AbstractMatrix{<:Real}) = transpose(A) function copy_transpose!(B::AbstractVecOrMat, ir_dest::AbstractRange{Int}, jr_dest::AbstractRange{Int}, diff --git a/base/sparse/sparsevector.jl b/base/sparse/sparsevector.jl index c140460f2e2af6..28f91f9d8cc009 100644 --- a/base/sparse/sparsevector.jl +++ b/base/sparse/sparsevector.jl @@ -1435,11 +1435,6 @@ vecnorm(x::SparseVectorUnion, p::Real=2) = vecnorm(nonzeros(x), p) ### linalg.jl -# Transpose -# (The only sparse matrix structure in base is CSC, so a one-row sparse matrix is worse than dense) -transpose(sv::SparseVector) = Transpose(sv) -adjoint(sv::SparseVector) = Adjoint(sv) - ### BLAS Level-1 # axpy diff --git a/test/sparse/higherorderfns.jl b/test/sparse/higherorderfns.jl index 719e9fa83ffdba..08b38ad8935195 100644 --- a/test/sparse/higherorderfns.jl +++ b/test/sparse/higherorderfns.jl @@ -415,8 +415,10 @@ end @test broadcast(*, s, V, A, X)::SparseMatrixCSC == sparse(broadcast(*, s, fV, fA, X)) @test broadcast!(*, Z, s, V, A, X) == sparse(broadcast(*, s, fV, fA, X)) # Issue #20954 combinations of sparse arrays and Adjoint/Transpose vectors - @test broadcast(+, A, adjoint(X))::SparseMatrixCSC == sparse(broadcast(+, fA, adjoint(X))) - @test broadcast(*, V, adjoint(X))::SparseMatrixCSC == sparse(broadcast(*, fV, adjoint(X))) + if X isa AbstractVector + @test broadcast(+, A, Adjoint(X))::SparseMatrixCSC == sparse(broadcast(+, fA, Adjoint(X))) + @test broadcast(*, V, Adjoint(X))::SparseMatrixCSC == sparse(broadcast(*, fV, Adjoint(X))) + end end @test V .+ ntuple(identity, N) isa Vector @test A .+ ntuple(identity, N) isa Matrix diff --git a/test/sparse/sparse.jl b/test/sparse/sparse.jl index 4dc81a7619e53b..eaee284faa1776 100644 --- a/test/sparse/sparse.jl +++ b/test/sparse/sparse.jl @@ -163,7 +163,7 @@ end am = sprand(1, 20, 0.2) av = squeeze(am, 1) @test ndims(av) == 1 - @test all(transpose(av) .== am) + @test all(Transpose(av) .== am) end end @@ -1313,7 +1313,7 @@ end end @testset "issue #9917" begin - @test sparse(adjoint([])) == reshape(sparse([]), 1, 0) + @test sparse(Adjoint([])) == reshape(sparse([]), 1, 0) @test Array(sparse([])) == zeros(0) @test_throws BoundsError sparse([])[1] @test_throws BoundsError sparse([])[1] = 1 diff --git a/test/sparse/sparsevector.jl b/test/sparse/sparsevector.jl index 94ef0bf7bac2ac..f4c5b238f384f7 100644 --- a/test/sparse/sparsevector.jl +++ b/test/sparse/sparsevector.jl @@ -385,14 +385,14 @@ end @test float(af) == af @test isa(af, SparseVector{Float64,Int}) @test exact_equal(af, SparseVector(8, [2, 5, 6], [12., 35., 72.])) - @test sparsevec(transpose(transpose(af))) == af + @test sparsevec(Transpose(Transpose(af))) == af # complex acp = complex(af) @test complex(acp) == acp @test isa(acp, SparseVector{ComplexF64,Int}) @test exact_equal(acp, SparseVector(8, [2, 5, 6], complex([12., 35., 72.]))) - @test sparsevec(adjoint(adjoint(acp))) == acp + @test sparsevec(Adjoint(Adjoint(acp))) == acp end @testset "Type conversion" begin