Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove special lowering for and deprecate .' #25125

Merged
merged 5 commits into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3098,7 +3098,7 @@ end
*(rowvec::RowVector, A::AbstractTriangular) = rvtranspose(transpose(A) * rvtranspose(rowvec))
*(rowvec::RowVector, transA::Transpose{<:Any,<:AbstractTriangular}) = rvtranspose(transA.parent * rvtranspose(rowvec))
*(A::AbstractTriangular, transrowvec::Transpose{<:Any,<:RowVector}) = A * rvtranspose(transrowvec.parent)
*(transA::Transpose{<:Any,<:AbstractTriangular}, transrowvec::Transpose{<:Any,<:RowVector}) = transA.parent.' * rvtranspose(transrowvec.parent)
*(transA::Transpose{<:Any,<:AbstractTriangular}, transrowvec::Transpose{<:Any,<:RowVector}) = transA * rvtranspose(transrowvec.parent)
*(rowvec::RowVector, adjA::Adjoint{<:Any,<:AbstractTriangular}) = rvadjoint(adjA.parent * rvadjoint(rowvec))
*(A::AbstractTriangular, adjrowvec::Adjoint{<:Any,<:RowVector}) = A * rvadjoint(adjrowvec.parent)
*(adjA::Adjoint{<:Any,<:AbstractTriangular}, adjrowvec::Adjoint{<:Any,<:RowVector}) = adjA.parent' * rvadjoint(adjrowvec.parent)
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end

## Structure query functions

issymmetric(A::BitMatrix) = size(A, 1)==size(A, 2) && count(!iszero, A - A.')==0
issymmetric(A::BitMatrix) = size(A, 1)==size(A, 2) && count(!iszero, A - transpose(A))==0
ishermitian(A::BitMatrix) = issymmetric(A)

function nonzero_chunks(chunks::Vector{UInt64}, pos0::Int, pos1::Int)
Expand Down
10 changes: 5 additions & 5 deletions base/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@ for (fname, elty) in ((:dgemv_,:Float64),
if trans == 'N' && (length(X) != n || length(Y) != m)
throw(DimensionMismatch("A has dimensions $(size(A)), X has length $(length(X)) and Y has length $(length(Y))"))
elseif trans == 'C' && (length(X) != m || length(Y) != n)
throw(DimensionMismatch("A' has dimensions $n, $m, X has length $(length(X)) and Y has length $(length(Y))"))
throw(DimensionMismatch("the adjoint of A has dimensions $n, $m, X has length $(length(X)) and Y has length $(length(Y))"))
elseif trans == 'T' && (length(X) != m || length(Y) != n)
throw(DimensionMismatch("A.' has dimensions $n, $m, X has length $(length(X)) and Y has length $(length(Y))"))
throw(DimensionMismatch("the transpose of A has dimensions $n, $m, X has length $(length(X)) and Y has length $(length(Y))"))
end
ccall((@blasfunc($fname), libblas), Void,
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
Expand Down Expand Up @@ -994,7 +994,7 @@ end
"""
syr!(uplo, alpha, x, A)

Rank-1 update of the symmetric matrix `A` with vector `x` as `alpha*x*x.' + A`.
Rank-1 update of the symmetric matrix `A` with vector `x` as `alpha*x*Transpose(x) + A`.
[`uplo`](@ref stdlib-blas-uplo) controls which triangle of `A` is updated. Returns `A`.
"""
function syr! end
Expand Down Expand Up @@ -1228,7 +1228,7 @@ end
"""
syrk!(uplo, trans, alpha, A, beta, C)

Rank-k update of the symmetric matrix `C` as `alpha*A*A.' + beta*C` or `alpha*A.'*A +
Rank-k update of the symmetric matrix `C` as `alpha*A*Transpose(A) + beta*C` or `alpha*Transpose(A)*A +
beta*C` according to [`trans`](@ref stdlib-blas-trans).
Only the [`uplo`](@ref stdlib-blas-uplo) triangle of `C` is used. Returns `C`.
"""
Expand All @@ -1239,7 +1239,7 @@ function syrk! end

Returns either the upper triangle or the lower triangle of `A`,
according to [`uplo`](@ref stdlib-blas-uplo),
of `alpha*A*A.'` or `alpha*A.'*A`,
of `alpha*A*Transpose(A)` or `alpha*Transpose(A)*A`,
according to [`trans`](@ref stdlib-blas-trans).
"""
function syrk end
Expand Down
10 changes: 5 additions & 5 deletions base/linalg/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
getindex(B::BunchKaufman, d::Symbol)

Extract the factors of the Bunch-Kaufman factorization `B`. The factorization can take the
two forms `L*D*L'` or `U*D*U'` (or `.'` in the complex symmetric case) where `L` is a
two forms `L*D*L'` or `U*D*U'` (or `L*D*Transpose(L)` in the complex symmetric case) where `L` is a
`UnitLowerTriangular` matrix, `U` is a `UnitUpperTriangular`, and `D` is a block diagonal
symmetric or Hermitian matrix with 1x1 or 2x2 blocks. The argument `d` can be
- `:D`: the block diagonal matrix
Expand Down Expand Up @@ -153,15 +153,15 @@ permutation:
3
2

julia> F[:L]*F[:D]*F[:L].' - A[F[:p], F[:p]]
julia> F[:L]*F[:D]*F[:L]' - A[F[:p], F[:p]]
3×3 Array{Float64,2}:
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0

julia> F = bkfact(Symmetric(A));

julia> F[:U]*F[:D]*F[:U].' - F[:P]*A*F[:P]'
julia> F[:U]*F[:D]*F[:U]' - F[:P]*A*F[:P]'
3×3 Array{Float64,2}:
0.0 0.0 0.0
0.0 0.0 0.0
Expand Down Expand Up @@ -192,13 +192,13 @@ function getindex(B::BunchKaufman{T}, d::Symbol) where {T<:BlasFloat}
if B.uplo == 'L'
return UnitLowerTriangular(LUD)
else
throw(ArgumentError("factorization is U*D*U.' but you requested L"))
throw(ArgumentError("factorization is U*D*Transpose(U) but you requested L"))
end
else # :U
if B.uplo == 'U'
return UnitUpperTriangular(LUD)
else
throw(ArgumentError("factorization is L*D*L.' but you requested U"))
throw(ArgumentError("factorization is L*D*Transpose(L) but you requested U"))
end
end
else
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/givens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

abstract type AbstractRotation{T} end

transpose(R::AbstractRotation) = error("transpose not implemented for $(typeof(R)). Consider using conjugate transpose (') instead of transpose (.').")
transpose(R::AbstractRotation) = error("transpose not implemented for $(typeof(R)). Consider using adjoint instead of transpose.")

function *(R::AbstractRotation{T}, A::AbstractVecOrMat{S}) where {T,S}
TS = typeof(zero(T)*zero(S) + zero(T)*zero(S))
Expand Down
28 changes: 14 additions & 14 deletions base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ end
"""
gels!(trans, A, B) -> (F, B, ssr)

Solves the linear equation `A * X = B`, `A.' * X =B`, or `A' * X = B` using
Solves the linear equation `A * X = B`, `Transpose(A) * X = B`, or `Adjoint(A) * X = B` using
a QR or LQ factorization. Modifies the matrix/vector `B` in place with the
solution. `A` is overwritten with its `QR` or `LQ` factorization. `trans`
may be one of `N` (no modification), `T` (transpose), or `C` (conjugate
Expand All @@ -994,7 +994,7 @@ gesv!(A::StridedMatrix, B::StridedVecOrMat)
"""
getrs!(trans, A, ipiv, B)

Solves the linear equation `A * X = B`, `A.' * X =B`, or `A' * X = B` for
Solves the linear equation `A * X = B`, `Transpose(A) * X = B`, or `Adjoint(A) * X = B` for
square `A`. Modifies the matrix/vector `B` in place with the solution. `A`
is the `LU` factorization from `getrf!`, with `ipiv` the pivoting
information. `trans` may be one of `N` (no modification), `T` (transpose),
Expand Down Expand Up @@ -1155,8 +1155,8 @@ end
"""
gesvx!(fact, trans, A, AF, ipiv, equed, R, C, B) -> (X, equed, R, C, B, rcond, ferr, berr, work)

Solves the linear equation `A * X = B` (`trans = N`), `A.' * X =B`
(`trans = T`), or `A' * X = B` (`trans = C`) using the `LU` factorization
Solves the linear equation `A * X = B` (`trans = N`), `Transpose(A) * X = B`
(`trans = T`), or `Adjoint(A) * X = B` (`trans = C`) using the `LU` factorization
of `A`. `fact` may be `E`, in which case `A` will be equilibrated and copied
to `AF`; `F`, in which case `AF` and `ipiv` from a previous `LU` factorization
are inputs; or `N`, in which case `A` will be copied to `AF` and then
Expand Down Expand Up @@ -2436,8 +2436,8 @@ gttrf!(dl::StridedVector, d::StridedVector, du::StridedVector)
"""
gttrs!(trans, dl, d, du, du2, ipiv, B)

Solves the equation `A * X = B` (`trans = N`), `A.' * X = B` (`trans = T`),
or `A' * X = B` (`trans = C`) using the `LU` factorization computed by
Solves the equation `A * X = B` (`trans = N`), `Transpose(A) * X = B` (`trans = T`),
or `Adjoint(A) * X = B` (`trans = C`) using the `LU` factorization computed by
`gttrf!`. `B` is overwritten with the solution `X`.
"""
gttrs!(trans::Char, dl::StridedVector, d::StridedVector, du::StridedVector, du2::StridedVector,
Expand Down Expand Up @@ -2866,7 +2866,7 @@ orgrq!(A::StridedMatrix, tau::StridedVector, k::Integer = length(tau))
"""
ormlq!(side, trans, A, tau, C)

Computes `Q * C` (`trans = N`), `Q.' * C` (`trans = T`), `Q' * C`
Computes `Q * C` (`trans = N`), `Transpose(Q) * C` (`trans = T`), `Adjoint(Q) * C`
(`trans = C`) for `side = L` or the equivalent right-sided multiplication
for `side = R` using `Q` from a `LQ` factorization of `A` computed using
`gelqf!`. `C` is overwritten.
Expand All @@ -2876,7 +2876,7 @@ ormlq!(side::Char, trans::Char, A::StridedMatrix, tau::StridedVector, C::Strided
"""
ormqr!(side, trans, A, tau, C)

Computes `Q * C` (`trans = N`), `Q.' * C` (`trans = T`), `Q' * C`
Computes `Q * C` (`trans = N`), `Transpose(Q) * C` (`trans = T`), `Adjoint(Q) * C`
(`trans = C`) for `side = L` or the equivalent right-sided multiplication
for `side = R` using `Q` from a `QR` factorization of `A` computed using
`geqrf!`. `C` is overwritten.
Expand All @@ -2886,7 +2886,7 @@ ormqr!(side::Char, trans::Char, A::StridedMatrix, tau::StridedVector, C::Strided
"""
ormql!(side, trans, A, tau, C)

Computes `Q * C` (`trans = N`), `Q.' * C` (`trans = T`), `Q' * C`
Computes `Q * C` (`trans = N`), `Transpose(Q) * C` (`trans = T`), `Adjoint(Q) * C`
(`trans = C`) for `side = L` or the equivalent right-sided multiplication
for `side = R` using `Q` from a `QL` factorization of `A` computed using
`geqlf!`. `C` is overwritten.
Expand All @@ -2896,7 +2896,7 @@ ormql!(side::Char, trans::Char, A::StridedMatrix, tau::StridedVector, C::Strided
"""
ormrq!(side, trans, A, tau, C)

Computes `Q * C` (`trans = N`), `Q.' * C` (`trans = T`), `Q' * C`
Computes `Q * C` (`trans = N`), `Transpose(Q) * C` (`trans = T`), `Adjoint(Q) * C`
(`trans = C`) for `side = L` or the equivalent right-sided multiplication
for `side = R` using `Q` from a `RQ` factorization of `A` computed using
`gerqf!`. `C` is overwritten.
Expand All @@ -2906,7 +2906,7 @@ ormrq!(side::Char, trans::Char, A::StridedMatrix, tau::StridedVector, C::Strided
"""
gemqrt!(side, trans, V, T, C)

Computes `Q * C` (`trans = N`), `Q.' * C` (`trans = T`), `Q' * C`
Computes `Q * C` (`trans = N`), `Transpose(Q) * C` (`trans = T`), `Adjoint(Q) * C`
(`trans = C`) for `side = L` or the equivalent right-sided multiplication
for `side = R` using `Q` from a `QR` factorization of `A` computed using
`geqrt!`. `C` is overwritten.
Expand Down Expand Up @@ -3306,8 +3306,8 @@ trtri!(uplo::Char, diag::Char, A::StridedMatrix)
"""
trtrs!(uplo, trans, diag, A, B)

Solves `A * X = B` (`trans = N`), `A.' * X = B` (`trans = T`), or
`A' * X = B` (`trans = C`) for (upper if `uplo = U`, lower if `uplo = L`)
Solves `A * X = B` (`trans = N`), `Transpose(A) * X = B` (`trans = T`), or
`Adjoint(A) * X = B` (`trans = C`) for (upper if `uplo = U`, lower if `uplo = L`)
triangular matrix `A`. If `diag = N`, `A` has non-unit diagonal elements.
If `diag = U`, all diagonal elements of `A` are one. `B` is overwritten
with the solution `X`.
Expand Down Expand Up @@ -3601,7 +3601,7 @@ trevc!(side::Char, howmny::Char, select::StridedVector{BlasInt}, T::StridedMatri
trrfs!(uplo, trans, diag, A, B, X, Ferr, Berr) -> (Ferr, Berr)

Estimates the error in the solution to `A * X = B` (`trans = N`),
`A.' * X = B` (`trans = T`), `A' * X = B` (`trans = C`) for `side = L`,
`Transpose(A) * X = B` (`trans = T`), `Adjoint(A) * X = B` (`trans = C`) for `side = L`,
or the equivalent equations a right-handed `side = R` `X * A` after
computing `X` using `trtrs!`. If `uplo = U`, `A` is upper triangular.
If `uplo = L`, `A` is lower triangular. If `diag = N`, `A` has non-unit
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/lq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lqfact(x::Number) = lqfact(fill(x,1,1))

Perform an LQ factorization of `A` such that `A = L*Q`. The default (`full = false`)
computes a factorization with possibly-rectangular `L` and `Q`, commonly the "thin"
factorization. The LQ factorization is the QR factorization of `A.'`. If the explicit,
factorization. The LQ factorization is the QR factorization of `Transpose(A)`. If the explicit,
full/square form of `Q` is requested via `full = true`, `L` is not extended with zeros.

!!! note
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ function ldiv!(adjA::Adjoint{<:Any,LU{T,Tridiagonal{T,V}}}, B::AbstractVecOrMat)
return B
end

/(B::AbstractMatrix,A::LU) = \(Transpose(A),Transpose(B)).'
/(B::AbstractMatrix,A::LU) = transpose(Transpose(A) \ Transpose(B))

# Conversions
convert(::Type{AbstractMatrix}, F::LU) = (F[:L] * F[:U])[invperm(F[:p]),:]
Expand Down
12 changes: 6 additions & 6 deletions base/linalg/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ function generic_matvecmul!(C::AbstractVector{R}, tA, A::AbstractVecOrMat, B::Ab
s = zero(A[aoffs + 1]*B[1] + A[aoffs + 1]*B[1])
end
for i = 1:nA
s += A[aoffs+i].'B[i]
s += Transpose(A[aoffs+i]) * B[i]
end
C[k] = s
end
Expand Down Expand Up @@ -629,7 +629,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
z2 = zero(A[i, 1]*B[j, 1] + A[i, 1]*B[j, 1])
Ctmp = convert(promote_type(R, typeof(z2)), z2)
for k = 1:nA
Ctmp += A[i, k]*B[j, k].'
Ctmp += A[i, k] * Transpose(B[j, k])
end
C[i,j] = Ctmp
end
Expand All @@ -649,7 +649,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
z2 = zero(A[1, i]*B[1, j] + A[1, i]*B[1, j])
Ctmp = convert(promote_type(R, typeof(z2)), z2)
for k = 1:nA
Ctmp += A[k, i].'B[k, j]
Ctmp += Transpose(A[k, i]) * B[k, j]
end
C[i,j] = Ctmp
end
Expand All @@ -658,7 +658,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
z2 = zero(A[1, i]*B[j, 1] + A[1, i]*B[j, 1])
Ctmp = convert(promote_type(R, typeof(z2)), z2)
for k = 1:nA
Ctmp += A[k, i].'B[j, k].'
Ctmp += Transpose(A[k, i]) * Transpose(B[j, k])
end
C[i,j] = Ctmp
end
Expand All @@ -667,7 +667,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
z2 = zero(A[1, i]*B[j, 1] + A[1, i]*B[j, 1])
Ctmp = convert(promote_type(R, typeof(z2)), z2)
for k = 1:nA
Ctmp += A[k, i].'B[j, k]'
Ctmp += Transpose(A[k, i]) * Adjoint(B[j, k])
end
C[i,j] = Ctmp
end
Expand All @@ -687,7 +687,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
z2 = zero(A[1, i]*B[j, 1] + A[1, i]*B[j, 1])
Ctmp = convert(promote_type(R, typeof(z2)), z2)
for k = 1:nA
Ctmp += A[k, i]'B[j, k].'
Ctmp += Adjoint(A[k, i]) * Transpose(B[j, k])
end
C[i,j] = Ctmp
end
Expand Down
27 changes: 11 additions & 16 deletions base/linalg/rowvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

A lazy-view wrapper of an [`AbstractVector`](@ref), which turns a length-`n` vector into a `1×n`
shaped row vector and represents the transpose of a vector (the elements are also transposed
recursively). This type is usually constructed (and unwrapped) via the [`transpose`](@ref)
function or `.'` operator (or related [`adjoint`](@ref) or `'` operator).
recursively).

By convention, a vector can be multiplied by a matrix on its left (`A * v`) whereas a row
vector can be multiplied by a matrix on its right (such that `v.' * A = (A.' * v).'`). It
vector can be multiplied by a matrix on its right (such that `RowVector(v) * A = RowVector(Transpose(A) * v)`). It
differs from a `1×n`-sized matrix by the facts that its transpose returns a vector and the
inner product `v1.' * v2` returns a scalar, but will otherwise behave similarly.
inner product `RowVector(v1) * v2` returns a scalar, but will otherwise behave similarly.

# Examples
```jldoctest
Expand All @@ -26,21 +25,17 @@ julia> RowVector(a)
1×4 RowVector{Int64,Array{Int64,1}}:
1 2 3 4

julia> a.'
1×4 RowVector{Int64,Array{Int64,1}}:
1 2 3 4

julia> a.'[3]
julia> RowVector(a)[3]
3

julia> a.'[1,3]
julia> RowVector(a)[1,3]
3

julia> a.'[3,1]
julia> RowVector(a)[3,1]
ERROR: BoundsError: attempt to access 1×4 RowVector{Int64,Array{Int64,1}} at index [3, 1]
[...]

julia> a.'*a
julia> RowVector(a)*a
30

julia> B = [1 2; 3 4; 5 6; 7 8]
Expand All @@ -50,7 +45,7 @@ julia> B = [1 2; 3 4; 5 6; 7 8]
5 6
7 8

julia> a.'*B
julia> RowVector(a)*B
1×2 RowVector{Int64,Array{Int64,1}}:
50 60
```
Expand Down Expand Up @@ -148,7 +143,7 @@ Return a [`ConjArray`](@ref) lazy view of the input, where each element is conju

# Examples
```jldoctest
julia> v = [1+im, 1-im].'
julia> v = RowVector([1+im, 1-im])
1×2 RowVector{Complex{Int64},Array{Complex{Int64},1}}:
1+1im 1-1im

Expand Down Expand Up @@ -214,7 +209,7 @@ IndexStyle(::Type{<:RowVector}) = IndexLinear()
end
sum(@inbounds(return rowvec[i]*vec[i]) for i = 1:length(vec))
end
@inline *(rowvec::RowVector, mat::AbstractMatrix) = rvtranspose(mat.' * rvtranspose(rowvec))
@inline *(rowvec::RowVector, mat::AbstractMatrix) = rvtranspose(Transpose(mat) * rvtranspose(rowvec))
*(::RowVector, ::RowVector) = throw(DimensionMismatch("Cannot multiply two transposed vectors"))
@inline *(vec::AbstractVector, rowvec::RowVector) = vec .* rowvec
*(vec::AbstractVector, rowvec::AbstractVector) = throw(DimensionMismatch("Cannot multiply two vectors"))
Expand All @@ -238,7 +233,7 @@ end
*(transvec::Transpose{<:Any,<:AbstractVector}, transrowvec::Transpose{<:Any,<:RowVector}) =
transpose(transvec.parent)*rvtranspose(transrowvec.parent)
*(transmat::Transpose{<:Any,<:AbstractMatrix}, transrowvec::Transpose{<:Any,<:RowVector}) =
(transmat.parent).' * rvtranspose(transrowvec.parent)
transmat * rvtranspose(transrowvec.parent)

*(::Transpose{<:Any,<:RowVector}, ::AbstractVector) =
throw(DimensionMismatch("Cannot multiply two vectors"))
Expand Down
Loading