Skip to content

Commit 4570ca7

Browse files
authored
Merge pull request #25083 from Sacha0/adjtransvec
transition linalg to Adjoint/Transpose externally
2 parents 8bf4e9d + 8244bdf commit 4570ca7

28 files changed

+642
-311
lines changed

base/deprecated.jl

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,6 +2990,131 @@ end
29902990
# re. A_mul_B deprecation, don't forget to:
29912991
# 1) delete function shims in base/linalg/linalg.jl
29922992

2993+
# methods involving RowVector from base/linalg/bidiag.jl, to deprecate
2994+
@eval Base.LinAlg begin
2995+
\(::Diagonal, ::RowVector) = _mat_ldiv_rowvec_error()
2996+
\(::Bidiagonal, ::RowVector) = _mat_ldiv_rowvec_error()
2997+
\(::Bidiagonal{<:Number}, ::RowVector{<:Number}) = _mat_ldiv_rowvec_error()
2998+
\(::Adjoint{<:Any,<:Bidiagonal}, ::RowVector) = _mat_ldiv_rowvec_error()
2999+
\(::Transpose{<:Any,<:Bidiagonal}, ::RowVector) = _mat_ldiv_rowvec_error()
3000+
\(::Adjoint{<:Number,<:Bidiagonal{<:Number}}, ::RowVector{<:Number}) = _mat_ldiv_rowvec_error()
3001+
\(::Transpose{<:Number,<:Bidiagonal{<:Number}}, ::RowVector{<:Number}) = _mat_ldiv_rowvec_error()
3002+
_mat_ldiv_rowvec_error() = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3003+
end
3004+
3005+
# methods involving RowVector from base/linalg/diagonal.jl, to deprecate
3006+
@eval Base.LinAlg begin
3007+
*(rowvec::RowVector, D::Diagonal) = rvtranspose(D * rvtranspose(rowvec)) # seems potentially incorrect without also transposing D?
3008+
*(D::Diagonal, transrowvec::Transpose{<:Any,<:RowVector}) = (rowvec = transrowvec.parent; D*rvtranspose(rowvec))
3009+
*(D::Diagonal, adjrowvec::Adjoint{<:Any,<:RowVector}) = (rowvec = adjrowvec.parent; D*rvadjoint(rowvec))
3010+
end
3011+
3012+
# methods involving RowVector from base/sparse/linalg.jl, to deprecate
3013+
@eval Base.SparseArrays begin
3014+
\(::SparseMatrixCSC, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3015+
\(::Adjoint{<:Any,<:SparseMatrixCSC}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3016+
\(::Transpose{<:Any,<:SparseMatrixCSC}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3017+
end
3018+
3019+
# methods involving RowVector from base/linalg/qr.jl, to deprecate
3020+
@eval Base.LinAlg begin
3021+
*(rowvec::RowVector, adjB::Adjoint{<:Any,<:AbstractQ}) = (B = adjB.parent; rvadjoint(B*rvadjoint(rowvec)))
3022+
end
3023+
3024+
# methods involving RowVector from base/linalg/qr.jl, to deprecate
3025+
@eval Base.LinAlg begin
3026+
*(A::RowVector, B::Adjoint{<:Any,<:AbstractRotation}) = A * adjoint(B.parent)
3027+
end
3028+
3029+
# methods involving RowVector from base/linalg/generic.jl, to deprecate
3030+
@eval Base.LinAlg begin
3031+
"""
3032+
norm(A::RowVector, q::Real=2)
3033+
3034+
For row vectors, return the ``q``-norm of `A`, which is equivalent to the p-norm with
3035+
value `p = q/(q-1)`. They coincide at `p = q = 2`.
3036+
3037+
The difference in norm between a vector space and its dual arises to preserve
3038+
the relationship between duality and the inner product, and the result is
3039+
consistent with the p-norm of `1 × n` matrix.
3040+
3041+
# Examples
3042+
```jldoctest
3043+
julia> v = [1; im];
3044+
3045+
julia> vc = v';
3046+
3047+
julia> norm(vc, 1)
3048+
1.0
3049+
3050+
julia> norm(v, 1)
3051+
2.0
3052+
3053+
julia> norm(vc, 2)
3054+
1.4142135623730951
3055+
3056+
julia> norm(v, 2)
3057+
1.4142135623730951
3058+
3059+
julia> norm(vc, Inf)
3060+
2.0
3061+
3062+
julia> norm(v, Inf)
3063+
1.0
3064+
```
3065+
"""
3066+
norm(tv::RowVector, q::Real) = q == Inf ? norm(rvtranspose(tv), 1) : norm(rvtranspose(tv), q/(q-1))
3067+
norm(tv::RowVector) = norm(rvtranspose(tv))
3068+
end
3069+
3070+
# methods involving RowVector from base/linalg/factorization.jl, to deprecate
3071+
@eval Base.LinAlg begin
3072+
\(A::Adjoint{<:Any,<:Factorization}, B::RowVector) = adjoint(A.parent) \ B
3073+
\(A::Transpose{<:Any,<:Factorization}, B::RowVector) = transpose(A.parent) \ B
3074+
\(A::Transpose{<:Any,<:Factorization{<:Real}}, B::RowVector) = transpose(A.parent) \ B
3075+
end
3076+
3077+
# methods involving RowVector from base/sparse/higherorderfns.jl, to deprecate
3078+
@eval Base.SparseArrays.HigherOrderFns begin
3079+
BroadcastStyle(::Type{<:Base.RowVector{T,<:Vector}}) where T = Broadcast.MatrixStyle()
3080+
end
3081+
3082+
# methods involving RowVector from base/linalg/symmetric.jl, to deprecate
3083+
@eval Base.LinAlg begin
3084+
*(A::RowVector, transB::Transpose{<:Any,<:RealHermSymComplexSym}) = A * transB.parent
3085+
*(A::RowVector, adjB::Adjoint{<:Any,<:RealHermSymComplexHerm}) = A * adjB.parent
3086+
\(A::HermOrSym{<:Any,<:StridedMatrix}, B::RowVector) = invoke(\, Tuple{AbstractMatrix, RowVector}, A, B)
3087+
*(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Adjoint{<:Any,<:RowVector}) = A.parent * B
3088+
*(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:RowVector}) = A.parent * B
3089+
*(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:RowVector}) = A.parent * B
3090+
*(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:RowVector}) = A.parent * B
3091+
end
3092+
3093+
# methods involving RowVector from base/linalg/triangular.jl, to deprecate
3094+
@eval Base.LinAlg begin
3095+
*(rowvec::RowVector, A::AbstractTriangular) = rvtranspose(transpose(A) * rvtranspose(rowvec))
3096+
*(rowvec::RowVector, transA::Transpose{<:Any,<:AbstractTriangular}) = rvtranspose(transA.parent * rvtranspose(rowvec))
3097+
*(A::AbstractTriangular, transrowvec::Transpose{<:Any,<:RowVector}) = A * rvtranspose(transrowvec.parent)
3098+
*(transA::Transpose{<:Any,<:AbstractTriangular}, transrowvec::Transpose{<:Any,<:RowVector}) = transA.parent.' * rvtranspose(transrowvec.parent)
3099+
*(rowvec::RowVector, adjA::Adjoint{<:Any,<:AbstractTriangular}) = rvadjoint(adjA.parent * rvadjoint(rowvec))
3100+
*(A::AbstractTriangular, adjrowvec::Adjoint{<:Any,<:RowVector}) = A * rvadjoint(adjrowvec.parent)
3101+
*(adjA::Adjoint{<:Any,<:AbstractTriangular}, adjrowvec::Adjoint{<:Any,<:RowVector}) = adjA.parent' * rvadjoint(adjrowvec.parent)
3102+
\(::Union{UpperTriangular,LowerTriangular}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3103+
\(::Union{UnitUpperTriangular,UnitLowerTriangular}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3104+
\(::Adjoint{<:Any,<:Union{UpperTriangular,LowerTriangular}}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3105+
\(::Adjoint{<:Any,<:Union{UnitUpperTriangular,UnitLowerTriangular}}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3106+
\(::Transpose{<:Any,<:Union{UpperTriangular,LowerTriangular}}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3107+
\(::Transpose{<:Any,<:Union{UnitUpperTriangular,UnitLowerTriangular}}, ::RowVector) = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
3108+
/(rowvec::RowVector, A::Union{UpperTriangular,LowerTriangular}) = rvtranspose(transpose(A) \ rvtranspose(rowvec))
3109+
/(rowvec::RowVector, A::Union{UnitUpperTriangular,UnitLowerTriangular}) = rvtranspose(transpose(A) \ rvtranspose(rowvec))
3110+
/(rowvec::RowVector, transA::Transpose{<:Any,<:Union{UpperTriangular,LowerTriangular}}) = rvtranspose(transA.parent \ rvtranspose(rowvec))
3111+
/(rowvec::RowVector, transA::Transpose{<:Any,<:Union{UnitUpperTriangular,UnitLowerTriangular}}) = rvtranspose(transA.parent \ rvtranspose(rowvec))
3112+
/(rowvec::RowVector, adjA::Adjoint{<:Any,<:Union{UpperTriangular,LowerTriangular}}) = /(rowvec, adjoint(adjA.parent))
3113+
/(rowvec::RowVector, adjA::Adjoint{<:Any,<:Union{UnitUpperTriangular,UnitLowerTriangular}}) = /(rowvec, adjoint(adjA.parent))
3114+
*(A::Adjoint{<:Any,<:AbstractTriangular}, B::Transpose{<:Any,<:RowVector}) = A * rvtranspose(B.parent)
3115+
*(A::Transpose{<:Any,<:AbstractTriangular}, B::Adjoint{<:Any,<:RowVector}) = A * rvadjoint(B.parent)
3116+
end
3117+
29933118
# issue #24822
29943119
@deprecate_binding Display AbstractDisplay
29953120

base/exports.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ export
9696
RoundNearestTiesUp,
9797
RoundToZero,
9898
RoundUp,
99+
Adjoint,
100+
Transpose,
99101
RowVector,
100102
AbstractSerializer,
101103
SerializationState,

base/linalg/adjtrans.jl

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,30 @@ Adjoint(x::Number) = adjoint(x)
4949
Transpose(x::Number) = transpose(x)
5050

5151
# unwrapping constructors
52-
# perhaps slightly odd, but necessary (at least till adjoint and transpose names are free)
5352
Adjoint(A::Adjoint) = A.parent
5453
Transpose(A::Transpose) = A.parent
54+
# normalizing unwrapping constructors
55+
# technically suspect, but at least fine for now
56+
Adjoint(A::Transpose) = conj(A.parent)
57+
Transpose(A::Adjoint) = conj(A.parent)
58+
59+
# eager lowercase quasi-constructors, unwrapping
60+
adjoint(A::Adjoint) = copy(A.parent)
61+
transpose(A::Transpose) = copy(A.parent)
62+
# eager lowercase quasi-constructors, normalizing
63+
# technically suspect, but at least fine for now
64+
adjoint(A::Transpose) = conj!(copy(A.parent))
65+
transpose(A::Adjoint) = conj!(copy(A.parent))
66+
67+
# lowercase quasi-constructors for vectors, TODO: deprecate
68+
adjoint(sv::AbstractVector) = Adjoint(sv)
69+
transpose(sv::AbstractVector) = Transpose(sv)
70+
5571

5672
# some aliases for internal convenience use
5773
const AdjOrTrans{T,S} = Union{Adjoint{T,S},Transpose{T,S}} where {T,S}
74+
const AdjointAbsVec{T} = Adjoint{T,<:AbstractVector}
75+
const TransposeAbsVec{T} = Transpose{T,<:AbstractVector}
5876
const AdjOrTransAbsVec{T} = AdjOrTrans{T,<:AbstractVector}
5977
const AdjOrTransAbsMat{T} = AdjOrTrans{T,<:AbstractMatrix}
6078

@@ -99,22 +117,100 @@ parent(A::AdjOrTrans) = A.parent
99117
vec(v::AdjOrTransAbsVec) = v.parent
100118

101119

120+
### concatenation
121+
# preserve Adjoint/Transpose wrapper around vectors
122+
# to retain the associated semantics post-concatenation
123+
hcat(avs::Union{Number,AdjointAbsVec}...) = _adjoint_hcat(avs...)
124+
hcat(tvs::Union{Number,TransposeAbsVec}...) = _transpose_hcat(tvs...)
125+
_adjoint_hcat(avs::Union{Number,AdjointAbsVec}...) = Adjoint(vcat(map(Adjoint, avs)...))
126+
_transpose_hcat(tvs::Union{Number,TransposeAbsVec}...) = Transpose(vcat(map(Transpose, tvs)...))
127+
typed_hcat(::Type{T}, avs::Union{Number,AdjointAbsVec}...) where {T} = Adjoint(typed_vcat(T, map(Adjoint, avs)...))
128+
typed_hcat(::Type{T}, tvs::Union{Number,TransposeAbsVec}...) where {T} = Transpose(typed_vcat(T, map(Transpose, tvs)...))
129+
# otherwise-redundant definitions necessary to prevent hitting the concat methods in sparse/sparsevector.jl
130+
hcat(avs::Adjoint{<:Any,<:Vector}...) = _adjoint_hcat(avs...)
131+
hcat(tvs::Transpose{<:Any,<:Vector}...) = _transpose_hcat(tvs...)
132+
hcat(avs::Adjoint{T,Vector{T}}...) where {T} = _adjoint_hcat(avs...)
133+
hcat(tvs::Transpose{T,Vector{T}}...) where {T} = _transpose_hcat(tvs...)
134+
135+
136+
### higher order functions
137+
# preserve Adjoint/Transpose wrapper around vectors
138+
# to retain the associated semantics post-map/broadcast
139+
140+
# vectorfy takes an Adoint/Transpose-wrapped vector and builds
141+
# an unwrapped vector with the entrywise-same contents
142+
vectorfy(x::Number) = x
143+
vectorfy(adjvec::AdjointAbsVec) = map(Adjoint, adjvec.parent)
144+
vectorfy(transvec::TransposeAbsVec) = map(Transpose, transvec.parent)
145+
vectorfyall(transformedvecs...) = (map(vectorfy, transformedvecs)...,)
146+
147+
# map over collections of Adjoint/Transpose-wrapped vectors
148+
# note that the caller's operation `f` should be applied to the entries of the wrapped
149+
# vectors, rather than the entires of the wrapped vector's parents. so first we use vectorfy
150+
# to build unwrapped vectors with entrywise-same contents as the wrapped input vectors.
151+
# then we map the caller's operation over that set of unwrapped vectors. but now re-wrapping
152+
# the resulting vector would inappropriately transform the result vector's entries. so
153+
# instead of simply mapping the caller's operation over the set of unwrapped vectors,
154+
# we map Adjoint/Transpose composed with the caller's operationt over the set of unwrapped
155+
# vectors. then re-wrapping the result vector yields a wrapped vector with the correct entries.
156+
map(f, avs::AdjointAbsVec...) = Adjoint(map(Adjointf, vectorfyall(avs...)...))
157+
map(f, tvs::TransposeAbsVec...) = Transpose(map(Transposef, vectorfyall(tvs...)...))
158+
159+
# broadcast over collections of Adjoint/Transpose-wrapped vectors and numbers
160+
# similar explanation for these definitions as for map above
161+
broadcast(f, avs::Union{Number,AdjointAbsVec}...) = Adjoint(broadcast(Adjointf, vectorfyall(avs...)...))
162+
broadcast(f, tvs::Union{Number,TransposeAbsVec}...) = Transpose(broadcast(Transposef, vectorfyall(tvs...) ...))
163+
164+
102165
### linear algebra
103166

104-
# definitions necessary for test/linalg/rowvector.jl to pass
105-
# should be cleaned up / revised as necessary in the future
106-
/(A::Transpose{<:Any,<:Vector}, B::Matrix) = /(transpose(A.parent), B)
107-
/(A::Transpose{<:Any,<:Vector}, B::Transpose{<:Any,<:Matrix}) = /(transpose(A.parent), B)
108-
*(A::Adjoint{<:Any,<:Matrix}, B::Adjoint{<:Any,<:Vector}) = *(adjoint(A.parent), adjoint(B.parent))
167+
## multiplication *
168+
169+
# Adjoint/Transpose-vector * vector
170+
*(u::AdjointAbsVec, v::AbstractVector) = dot(u.parent, v)
171+
*(u::TransposeAbsVec{T}, v::AbstractVector{T}) where {T<:Real} = dot(u.parent, v)
172+
function *(u::TransposeAbsVec, v::AbstractVector)
173+
@boundscheck length(u) == length(v) || throw(DimensionMismatch())
174+
return sum(@inbounds(return u[k]*v[k]) for k in 1:length(u))
175+
end
176+
# vector * Adjoint/Transpose-vector
177+
*(u::AbstractVector, v::AdjOrTransAbsVec) = broadcast(*, u, v)
178+
# Adjoint/Transpose-vector * Adjoint/Transpose-vector
179+
# (necessary for disambiguation with fallback methods in linalg/matmul)
180+
*(u::AdjointAbsVec, v::AdjointAbsVec) = throw(MethodError(*, (u, v)))
181+
*(u::TransposeAbsVec, v::TransposeAbsVec) = throw(MethodError(*, (u, v)))
182+
183+
# Adjoint/Transpose-vector * matrix
184+
*(u::AdjointAbsVec, A::AbstractMatrix) = Adjoint(Adjoint(A) * u.parent)
185+
*(u::TransposeAbsVec, A::AbstractMatrix) = Transpose(Transpose(A) * u.parent)
186+
# Adjoint/Transpose-vector * Adjoint/Transpose-matrix
187+
*(u::AdjointAbsVec, A::Adjoint{<:Any,<:AbstractMatrix}) = Adjoint(A.parent * u.parent)
188+
*(u::TransposeAbsVec, A::Transpose{<:Any,<:AbstractMatrix}) = Transpose(A.parent * u.parent)
189+
190+
191+
## pseudoinversion
192+
pinv(v::AdjointAbsVec, tol::Real = 0) = pinv(v.parent, tol).parent
193+
pinv(v::TransposeAbsVec, tol::Real = 0) = pinv(conj(v.parent)).parent
194+
195+
196+
## left-division \
197+
\(u::AdjOrTransAbsVec, v::AdjOrTransAbsVec) = pinv(u) * v
198+
199+
200+
## right-division \
201+
/(u::AdjointAbsVec, A::AbstractMatrix) = Adjoint(Adjoint(A) \ u.parent)
202+
/(u::TransposeAbsVec, A::AbstractMatrix) = Transpose(Transpose(A) \ u.parent)
109203

110204

111205
# dismabiguation methods
112-
*(A::Transpose{<:Any,<:AbstractVector}, B::Adjoint{<:Any,<:AbstractVector}) = transpose(A.parent) * B
113-
*(A::Transpose{<:Any,<:AbstractVector}, B::Adjoint{<:Any,<:AbstractMatrix}) = transpose(A.parent) * B
114-
*(A::Transpose{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractVector}) = A * adjoint(B.parent)
206+
*(A::AdjointAbsVec, B::Transpose{<:Any,<:AbstractMatrix}) = A * transpose(B.parent)
207+
*(A::TransposeAbsVec, B::Adjoint{<:Any,<:AbstractMatrix}) = A * adjoint(B.parent)
115208
*(A::Transpose{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractMatrix}) = transpose(A.parent) * B
116-
*(A::Adjoint{<:Any,<:AbstractVector}, B::Transpose{<:Any,<:AbstractVector}) = adjoint(A.parent) * B
117-
*(A::Adjoint{<:Any,<:AbstractVector}, B::Transpose{<:Any,<:AbstractMatrix}) = adjoint(A.parent) * B
118-
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractVector}) = A * adjoint(B.parent)
119-
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Transpose{<:Any,<:AbstractVector}) = A * transpose(B.parent)
120-
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Transpose{<:Any,<:AbstractMatrix}) = adjoint(A.parent) * B
209+
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Transpose{<:Any,<:AbstractMatrix}) = A * transpose(B.parent)
210+
# Adj/Trans-vector * Trans/Adj-vector, shouldn't exist, here for ambiguity resolution? TODO: test removal
211+
*(A::Adjoint{<:Any,<:AbstractVector}, B::Transpose{<:Any,<:AbstractVector}) = throw(MethodError(*, (A, B)))
212+
*(A::Transpose{<:Any,<:AbstractVector}, B::Adjoint{<:Any,<:AbstractVector}) = throw(MethodError(*, (A, B)))
213+
# Adj/Trans-matrix * Trans/Adj-vector, shouldn't exist, here for ambiguity resolution? TODO: test removal
214+
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractVector}) = throw(MethodError(*, (A, B)))
215+
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Transpose{<:Any,<:AbstractVector}) = throw(MethodError(*, (A, B)))
216+
*(A::Transpose{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractVector}) = throw(MethodError(*, (A, B)))

base/linalg/bidiag.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,6 @@ mul!(C::AbstractMatrix, A::BiTri, B::Transpose{<:Any,<:AbstractVecOrMat}) = A_mu
348348
mul!(C::AbstractMatrix, A::BiTri, B::Adjoint{<:Any,<:AbstractVecOrMat}) = A_mul_B_td!(C, A, B)
349349
mul!(C::AbstractVector, A::BiTri, B::Transpose{<:Any,<:AbstractVecOrMat}) = throw(MethodError(mul!, (C, A, B)))
350350

351-
\(::Diagonal, ::RowVector) = _mat_ldiv_rowvec_error()
352-
\(::Bidiagonal, ::RowVector) = _mat_ldiv_rowvec_error()
353-
\(::Bidiagonal{<:Number}, ::RowVector{<:Number}) = _mat_ldiv_rowvec_error()
354-
\(::Adjoint{<:Any,<:Bidiagonal}, ::RowVector) = _mat_ldiv_rowvec_error()
355-
\(::Transpose{<:Any,<:Bidiagonal}, ::RowVector) = _mat_ldiv_rowvec_error()
356-
\(::Adjoint{<:Number,<:Bidiagonal{<:Number}}, ::RowVector{<:Number}) = _mat_ldiv_rowvec_error()
357-
\(::Transpose{<:Number,<:Bidiagonal{<:Number}}, ::RowVector{<:Number}) = _mat_ldiv_rowvec_error()
358-
_mat_ldiv_rowvec_error() = throw(DimensionMismatch("Cannot left-divide matrix by transposed vector"))
359-
360351
function check_A_mul_B!_sizes(C, A, B)
361352
nA, mA = size(A)
362353
nB, mB = size(B)

base/linalg/diagonal.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,6 @@ rdiv!(A::AbstractMatrix{T}, transD::Transpose{<:Any,<:Diagonal{T}}) where {T} =
358358
\(adjF::Adjoint{<:Any,<:Factorization}, D::Diagonal) =
359359
(F = adjF.parent; ldiv!(Adjoint(F), Matrix{typeof(oneunit(eltype(D))/oneunit(eltype(F)))}(D)))
360360

361-
# Methods to resolve ambiguities with `Diagonal`
362-
@inline *(rowvec::RowVector, D::Diagonal) = transpose(D * transpose(rowvec))
363-
*(D::Diagonal, transrowvec::Transpose{<:Any,<:RowVector}) = (rowvec = transrowvec.parent; D*transpose(rowvec))
364-
*(D::Diagonal, adjrowvec::Adjoint{<:Any,<:RowVector}) = (rowvec = adjrowvec.parent; D*adjoint(rowvec))
365-
366361
conj(D::Diagonal) = Diagonal(conj(D.diag))
367362
transpose(D::Diagonal{<:Number}) = D
368363
transpose(D::Diagonal) = Diagonal(transpose.(D.diag))

base/linalg/factorization.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,3 @@ ldiv!(Y::AbstractVecOrMat, transA::Transpose{<:Any,<:Factorization}, B::Abstract
8585
# fallback methods for transposed solves
8686
\(transF::Transpose{<:Any,<:Factorization{<:Real}}, B::AbstractVecOrMat) = (F = transF.parent; \(Adjoint(F), B))
8787
\(transF::Transpose{<:Any,<:Factorization}, B::AbstractVecOrMat) = (F = transF.parent; conj.(\(Adjoint(F), conj.(B))))
88-
89-
# dismabiguation methods
90-
\(A::Adjoint{<:Any,<:Factorization}, B::RowVector) = adjoint(A.parent) \ B
91-
\(A::Transpose{<:Any,<:Factorization}, B::RowVector) = transpose(A.parent) \ B
92-
\(A::Transpose{<:Any,<:Factorization{<:Real}}, B::RowVector) = transpose(A.parent) \ B

base/linalg/generic.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,13 +576,12 @@ This is equivalent to [`vecnorm`](@ref).
576576
"""
577577
@inline norm(x::Number, p::Real=2) = vecnorm(x, p)
578578

579-
@inline norm(tv::RowVector) = norm(transpose(tv))
580-
581579
"""
582-
norm(A::RowVector, q::Real=2)
580+
norm(A::Adjoint{<:Any,<:AbstracVector}, q::Real=2)
581+
norm(A::Transpose{<:Any,<:AbstracVector}, q::Real=2)
583582
584-
For row vectors, return the ``q``-norm of `A`, which is equivalent to the p-norm with
585-
value `p = q/(q-1)`. They coincide at `p = q = 2`.
583+
For Adjoint/Transpose-wrapped vectors, return the ``q``-norm of `A`, which is
584+
equivalent to the p-norm with value `p = q/(q-1)`. They coincide at `p = q = 2`.
586585
587586
The difference in norm between a vector space and its dual arises to preserve
588587
the relationship between duality and the inner product, and the result is
@@ -613,7 +612,10 @@ julia> norm(v, Inf)
613612
1.0
614613
```
615614
"""
616-
@inline norm(tv::RowVector, q::Real) = q == Inf ? norm(transpose(tv), 1) : norm(transpose(tv), q/(q-1))
615+
norm(v::TransposeAbsVec, q::Real) = q == Inf ? norm(v.parent, 1) : norm(v.parent, q/(q-1))
616+
norm(v::AdjointAbsVec, q::Real) = q == Inf ? norm(conj(v.parent), 1) : norm(conj(v.parent), q/(q-1))
617+
norm(v::AdjointAbsVec) = norm(conj(v.parent))
618+
norm(v::TransposeAbsVec) = norm(v.parent)
617619

618620
function vecdot(x::AbstractArray, y::AbstractArray)
619621
lx = _length(x)

base/linalg/givens.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ end
379379
*(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractRotation}) = A.parent * B
380380
# dismabiguation methods: *(Diag/RowVec/AbsTri, Adj of AbstractRotation)
381381
*(A::Diagonal, B::Adjoint{<:Any,<:AbstractRotation}) = A * adjoint(B.parent)
382-
*(A::RowVector, B::Adjoint{<:Any,<:AbstractRotation}) = A * adjoint(B.parent)
383382
*(A::AbstractTriangular, B::Adjoint{<:Any,<:AbstractRotation}) = A * adjoint(B.parent)
384383
# moar disambiguation
385384
mul!(A::QRPackedQ, B::Adjoint{<:Any,<:Givens}) = throw(MethodError(mul!, (A, B)))

0 commit comments

Comments
 (0)