Skip to content

Commit 6919e03

Browse files
committed
more verbose type names
1 parent acb68ca commit 6919e03

File tree

13 files changed

+38
-45
lines changed

13 files changed

+38
-45
lines changed

NEWS.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ Standard library changes
103103
* The shape of an `UpperHessenberg` matrix is preserved under certain arithmetic operations, e.g. when multiplying or dividing by an `UpperTriangular` matrix. ([#40039])
104104
* `cis(A)` now supports matrix arguments ([#40194]).
105105
* `dot` now supports `UniformScaling` with `AbstractMatrix` ([#40250]).
106-
* `qr[!]` and `lu[!]` now support `PivotingStrategy` values as their optional `pivot` argument:
107-
defaults are `qr(A, NoPivot())` (vs. `qr(A, ColNorm())` for pivoting) and `lu(A, RowMax())`
108-
(vs. `lu(A, NoPivot())` without pivoting); the former `Val{true/false}`-based calls are deprecated. ([#40623])
106+
* `qr[!]` and `lu[!]` now support `LinearAlgebra.PivotingStrategy` (singleton type) values
107+
as their optional `pivot` argument: defaults are `qr(A, NoPivot())` (vs.
108+
`qr(A, ColumnNorm())` for pivoting) and `lu(A, RowMaximum())` (vs. `lu(A, NoPivot())`
109+
without pivoting); the former `Val{true/false}`-based calls are deprecated. ([#40623])
109110

110111
#### Markdown
111112

stdlib/LinearAlgebra/src/LinearAlgebra.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export
3535
BunchKaufman,
3636
Cholesky,
3737
CholeskyPivoted,
38-
ColNorm,
38+
ColumnNorm,
3939
Eigen,
4040
GeneralizedEigen,
4141
GeneralizedSVD,
@@ -50,7 +50,7 @@ export
5050
Schur,
5151
SVD,
5252
Hermitian,
53-
RowMax,
53+
RowMaximum,
5454
Symmetric,
5555
LowerTriangular,
5656
UpperTriangular,
@@ -169,8 +169,8 @@ struct QRIteration <: Algorithm end
169169

170170
abstract type PivotingStrategy end
171171
struct NoPivot <: PivotingStrategy end
172-
struct RowMax <: PivotingStrategy end
173-
struct ColNorm <: PivotingStrategy end
172+
struct RowMaximum <: PivotingStrategy end
173+
struct ColumnNorm <: PivotingStrategy end
174174

175175
# Check that stride of matrix/vector is 1
176176
# Writing like this to avoid splatting penalty when called with multiple arguments,

stdlib/LinearAlgebra/src/dense.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ function factorize(A::StridedMatrix{T}) where T
13711371
end
13721372
return lu(A)
13731373
end
1374-
qr(A, ColNorm())
1374+
qr(A, ColumnNorm())
13751375
end
13761376
factorize(A::Adjoint) = adjoint(factorize(parent(A)))
13771377
factorize(A::Transpose) = transpose(factorize(parent(A)))

stdlib/LinearAlgebra/src/factorization.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ size(F::Adjoint{<:Any,<:Factorization}) = reverse(size(parent(F)))
1616
size(F::Transpose{<:Any,<:Factorization}) = reverse(size(parent(F)))
1717

1818
checkpositivedefinite(info) = info == 0 || throw(PosDefException(info))
19-
checknonsingular(info, ::RowMax) = info == 0 || throw(SingularException(info))
19+
checknonsingular(info, ::RowMaximum) = info == 0 || throw(SingularException(info))
2020
checknonsingular(info, ::NoPivot) = info == 0 || throw(ZeroPivotException(info))
21-
checknonsingular(info) = checknonsingular(info, RowMax())
21+
checknonsingular(info) = checknonsingular(info, RowMaximum())
2222

2323
"""
2424
issuccess(F::Factorization)

stdlib/LinearAlgebra/src/generic.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ function (\)(A::AbstractMatrix, B::AbstractVecOrMat)
11411141
end
11421142
return lu(A) \ B
11431143
end
1144-
return qr(A, ColNorm()) \ B
1144+
return qr(A, ColumnNorm()) \ B
11451145
end
11461146

11471147
(\)(a::AbstractVector, b::AbstractArray) = pinv(a) * b

stdlib/LinearAlgebra/src/lu.jl

+12-20
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,26 @@ adjoint(F::LU) = Adjoint(F)
7676
transpose(F::LU) = Transpose(F)
7777

7878
# StridedMatrix
79-
lu!(A::StridedMatrix{<:BlasFloat}; check::Bool = true) = lu!(A, RowMax(); check=check)
80-
function lu!(A::StridedMatrix{T}, ::RowMax; check::Bool = true) where {T<:BlasFloat}
79+
lu!(A::StridedMatrix{<:BlasFloat}; check::Bool = true) = lu!(A, RowMaximum(); check=check)
80+
function lu!(A::StridedMatrix{T}, ::RowMaximum; check::Bool = true) where {T<:BlasFloat}
8181
lpt = LAPACK.getrf!(A)
8282
check && checknonsingular(lpt[3])
8383
return LU{T,typeof(A)}(lpt[1], lpt[2], lpt[3])
8484
end
8585
function lu!(A::StridedMatrix{<:BlasFloat}, pivot::NoPivot; check::Bool = true)
8686
return generic_lufact!(A, pivot; check = check)
8787
end
88-
function lu!(A::HermOrSym, pivot::PivotingStrategy = RowMax(); check::Bool = true)
88+
function lu!(A::HermOrSym, pivot::Union{RowMaximum,NoPivot} = RowMaximum(); check::Bool = true)
8989
copytri!(A.data, A.uplo, isa(A, Hermitian))
9090
lu!(A.data, pivot; check = check)
9191
end
9292
# for backward compatibility
9393
# TODO: remove towards Julia v2
94-
@deprecate lu!(A::Union{StridedMatrix,HermOrSym,Tridiagonal}, ::Val{true}; check::Bool = true) lu!(A, RowMax(); check=check)
94+
@deprecate lu!(A::Union{StridedMatrix,HermOrSym,Tridiagonal}, ::Val{true}; check::Bool = true) lu!(A, RowMaximum(); check=check)
9595
@deprecate lu!(A::Union{StridedMatrix,HermOrSym,Tridiagonal}, ::Val{false}; check::Bool = true) lu!(A, NoPivot(); check=check)
9696

9797
"""
98-
lu!(A, pivot = RowMax(); check = true) -> LU
98+
lu!(A, pivot = RowMaximum(); check = true) -> LU
9999
100100
`lu!` is the same as [`lu`](@ref), but saves space by overwriting the
101101
input `A`, instead of creating a copy. An [`InexactError`](@ref)
@@ -131,26 +131,22 @@ Stacktrace:
131131
[...]
132132
```
133133
"""
134-
lu!(A::StridedMatrix, pivot::PivotingStrategy = RowMax(); check::Bool = true) =
134+
lu!(A::StridedMatrix, pivot::Union{RowMaximum,NoPivot} = RowMaximum(); check::Bool = true) =
135135
generic_lufact!(A, pivot; check = check)
136-
function generic_lufact!(A::StridedMatrix{T}, pivot::PivotingStrategy = RowMax();
136+
function generic_lufact!(A::StridedMatrix{T}, pivot::Union{RowMaximum,NoPivot} = RowMaximum();
137137
check::Bool = true) where {T}
138138
# Extract values
139139
m, n = size(A)
140140
minmn = min(m,n)
141141

142-
if pivot !== RowMax() && pivot !== NoPivot()
143-
throw(ArgumentError("only `RowMax()` and `NoPivot()` are supported as `pivot` argument but you supplied `$pivot`"))
144-
end
145-
146142
# Initialize variables
147143
info = 0
148144
ipiv = Vector{BlasInt}(undef, minmn)
149145
@inbounds begin
150146
for k = 1:minmn
151147
# find index max
152148
kp = k
153-
if pivot === RowMax() && k < m
149+
if pivot === RowMaximum() && k < m
154150
amax = abs(A[k, k])
155151
for i = k+1:m
156152
absi = abs(A[i,k])
@@ -211,7 +207,7 @@ end
211207

212208
# for all other types we must promote to a type which is stable under division
213209
"""
214-
lu(A, pivot = RowMax(); check = true) -> F::LU
210+
lu(A, pivot = RowMaximum(); check = true) -> F::LU
215211
216212
Compute the LU factorization of `A`.
217213
@@ -278,12 +274,12 @@ julia> l == F.L && u == F.U && p == F.p
278274
true
279275
```
280276
"""
281-
function lu(A::AbstractMatrix{T}, pivot::PivotingStrategy = RowMax(); check::Bool = true) where {T}
277+
function lu(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot} = RowMaximum(); check::Bool = true) where {T}
282278
S = lutype(T)
283279
lu!(copy_oftype(A, S), pivot; check = check)
284280
end
285281
# TODO: remove for Julia v2.0
286-
@deprecate lu(A::AbstractMatrix, ::Val{true}; check::Bool = true) lu(A, RowMax(); check=check)
282+
@deprecate lu(A::AbstractMatrix, ::Val{true}; check::Bool = true) lu(A, RowMaximum(); check=check)
287283
@deprecate lu(A::AbstractMatrix, ::Val{false}; check::Bool = true) lu(A, NoPivot(); check=check)
288284

289285

@@ -495,14 +491,10 @@ inv(A::LU{<:BlasFloat,<:StridedMatrix}) = inv!(copy(A))
495491
# Tridiagonal
496492

497493
# See dgttrf.f
498-
function lu!(A::Tridiagonal{T,V}, pivot::PivotingStrategy = RowMax(); check::Bool = true) where {T,V}
494+
function lu!(A::Tridiagonal{T,V}, pivot::Union{RowMaximum,NoPivot} = RowMaximum(); check::Bool = true) where {T,V}
499495
# Extract values
500496
n = size(A, 1)
501497

502-
if pivot !== RowMax() && pivot !== NoPivot()
503-
throw(ArgumentError("only `RowMax()` and `NoPivot()` are supported as `pivot` argument but you supplied `$pivot`"))
504-
end
505-
506498
# Initialize variables
507499
info = 0
508500
ipiv = Vector{BlasInt}(undef, n)

stdlib/LinearAlgebra/src/qr.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ end
248248
# LAPACK version
249249
qr!(A::StridedMatrix{<:BlasFloat}, ::NoPivot; blocksize=36) =
250250
QRCompactWY(LAPACK.geqrt!(A, min(min(size(A)...), blocksize))...)
251-
qr!(A::StridedMatrix{<:BlasFloat}, ::ColNorm) = QRPivoted(LAPACK.geqp3!(A)...)
251+
qr!(A::StridedMatrix{<:BlasFloat}, ::ColumnNorm) = QRPivoted(LAPACK.geqp3!(A)...)
252252

253253
# Generic fallbacks
254254

@@ -293,10 +293,10 @@ Stacktrace:
293293
```
294294
"""
295295
qr!(A::AbstractMatrix, ::NoPivot) = qrfactUnblocked!(A)
296-
qr!(A::AbstractMatrix, ::ColNorm) = qrfactPivotedUnblocked!(A)
296+
qr!(A::AbstractMatrix, ::ColumnNorm) = qrfactPivotedUnblocked!(A)
297297
qr!(A::AbstractMatrix) = qr!(A, NoPivot())
298298
# TODO: Remove in Julia v2.0
299-
@deprecate qr!(A::AbstractMatrix, ::Val{true}) qr!(A, ColNorm())
299+
@deprecate qr!(A::AbstractMatrix, ::Val{true}) qr!(A, ColumnNorm())
300300
@deprecate qr!(A::AbstractMatrix, ::Val{false}) qr!(A, NoPivot())
301301

302302
_qreltype(::Type{T}) where T = typeof(zero(T)/sqrt(abs2(one(T))))
@@ -313,7 +313,7 @@ A = Q R
313313
314314
The returned object `F` stores the factorization in a packed format:
315315
316-
- if `pivot == ColNorm()` then `F` is a [`QRPivoted`](@ref) object,
316+
- if `pivot == ColumnNorm()` then `F` is a [`QRPivoted`](@ref) object,
317317
318318
- otherwise if the element type of `A` is a BLAS type ([`Float32`](@ref), [`Float64`](@ref),
319319
`ComplexF32` or `ComplexF64`), then `F` is a [`QRCompactWY`](@ref) object,
@@ -387,7 +387,7 @@ function qr(A::AbstractMatrix{T}, arg...; kwargs...) where T
387387
end
388388
# TODO: remove in Julia v2.0
389389
@deprecate qr(A::AbstractMatrix, ::Val{false}; kwargs...) qr(A, NoPivot(); kwargs...)
390-
@deprecate qr(A::AbstractMatrix, ::Val{true}; kwargs...) qr(A, ColNorm(); kwargs...)
390+
@deprecate qr(A::AbstractMatrix, ::Val{true}; kwargs...) qr(A, ColumnNorm(); kwargs...)
391391

392392
qr(x::Number) = qr(fill(x,1,1))
393393
function qr(v::AbstractVector)

stdlib/LinearAlgebra/test/diagonal.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ end
565565
D = Diagonal(randn(5))
566566
Q = qr(randn(5, 5)).Q
567567
@test D * Q' == Array(D) * Q'
568-
Q = qr(randn(5, 5), ColNorm()).Q
568+
Q = qr(randn(5, 5), ColumnNorm()).Q
569569
@test_throws ArgumentError lmul!(Q, D)
570570
end
571571

stdlib/LinearAlgebra/test/generic.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ LinearAlgebra.Transpose(a::ModInt{n}) where {n} = transpose(a)
388388
Base.abs(a::ModInt{n}) where {n} = a
389389
Base.:<(a::ModInt{n}, b::ModInt{n}) where {n} = a.k < b.k
390390

391-
@test A*(lu(A, RowMax())\b) == b
391+
@test A*(lu(A, RowMaximum())\b) == b
392392
end
393393

394394
@testset "Issue 18742" begin

stdlib/LinearAlgebra/test/lq.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ rectangularQ(Q::LinearAlgebra.LQPackedQ) = convert(Array, Q)
4040
lqa = lq(a)
4141
x = lqa\b
4242
l,q = lqa.L, lqa.Q
43-
qra = qr(a, ColNorm())
43+
qra = qr(a, ColumnNorm())
4444
@testset "Basic ops" begin
4545
@test size(lqa,1) == size(a,1)
4646
@test size(lqa,3) == 1

stdlib/LinearAlgebra/test/qr.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ rectangularQ(Q::LinearAlgebra.AbstractQ) = convert(Array, Q)
102102
@test Base.propertynames(qra) == (:R, :Q)
103103
end
104104
@testset "(Automatic) Fat (pivoted) QR decomposition" begin
105-
@inferred qr(a, ColNorm())
105+
@inferred qr(a, ColumnNorm())
106106

107107
qrpa = factorize(a[1:n1,:])
108108
q,r = qrpa.Q, qrpa.R
@@ -254,7 +254,7 @@ end
254254
A = zeros(1, 2)
255255
B = zeros(1, 1)
256256
@test A \ B == zeros(2, 1)
257-
@test qr(A, ColNorm()) \ B == zeros(2, 1)
257+
@test qr(A, ColumnNorm()) \ B == zeros(2, 1)
258258
end
259259

260260
@testset "Issue 24107" begin
@@ -276,7 +276,7 @@ end
276276
@test A \b ldiv!(c, qr(A ), b)
277277
@test b == b0
278278
c0 = copy(c)
279-
@test Ac\c ldiv!(b, qr(Ac, ColNorm()), c)
279+
@test Ac\c ldiv!(b, qr(Ac, ColumnNorm()), c)
280280
@test c0 == c
281281
end
282282

@@ -293,7 +293,7 @@ end
293293

294294
@testset "det(Q::Union{QRCompactWYQ, QRPackedQ})" begin
295295
# 40 is the number larger than the default block size 36 of QRCompactWY
296-
@testset for n in [1:3; 40], m in [1:3; 40], pivot in (NoPivot(), ColNorm())
296+
@testset for n in [1:3; 40], m in [1:3; 40], pivot in (NoPivot(), ColumnNorm())
297297
@testset "real" begin
298298
@testset for k in 0:min(n, m, 5)
299299
A = cat(Array(I(k)), randn(n - k, m - k); dims=(1, 2))

stdlib/LinearAlgebra/test/special.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ end
192192
a = rand(n,n)
193193
atri = typ(a)
194194
b = rand(n,n)
195-
qrb = qr(b, ColNorm())
195+
qrb = qr(b, ColumnNorm())
196196
@test *(atri, adjoint(qrb.Q)) Matrix(atri) * qrb.Q'
197197
@test rmul!(copy(atri), adjoint(qrb.Q)) Matrix(atri) * qrb.Q'
198198
qrb = qr(b, NoPivot())

stdlib/LinearAlgebra/test/uniformscaling.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ end
500500

501501
@testset "Factorization solutions" begin
502502
J = complex(randn(),randn()) * I
503-
qrp = A -> qr(A, ColNorm())
503+
qrp = A -> qr(A, ColumnNorm())
504504

505505
# thin matrices
506506
X = randn(3,2)

0 commit comments

Comments
 (0)