Skip to content

Commit 2f93c94

Browse files
Merge pull request #27212 from Sacha0/breakless
once more unto the decomposition breach, dear friends!
2 parents 13b2f2b + edf5bd2 commit 2f93c94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1313
-1146
lines changed

NEWS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,21 @@ This section lists changes that do not have deprecation warnings.
230230
* `readuntil` now does *not* include the delimiter in its result, matching the
231231
behavior of `readline`. Pass `keep=true` to get the old behavior ([#25633]).
232232

233+
* `lu` methods now return decomposition objects such as `LU` rather than
234+
tuples of arrays or tuples of numbers ([#26997], [#27159], [#27212]).
235+
236+
* `schur` methods now return decomposition objects such as `Schur` and
237+
`GeneralizedSchur` rather than tuples of arrays ([#26997], [#27159], [#27212]).
238+
239+
* `lq` methods now return decomposition objects such as `LQ`
240+
rather than tuples of arrays ([#26997], [#27159], [#27212]).
241+
242+
* `qr` methods now return decomposition objects such as `QR`, `QRPivoted`,
243+
and `QRCompactWY` rather than tuples of arrays ([#26997], [#27159], [#27212]).
244+
245+
* `svd` methods now return decomposition objects such as `SVD` and
246+
`GeneralizedSVD` rather than tuples of arrays or tuples of numbers ([#26997], [#27159], [#27212]).
247+
233248
* `countlines` now always counts the last non-empty line even if it does not
234249
end with EOL, matching the behavior of `eachline` and `readlines` ([#25845]).
235250

@@ -698,6 +713,31 @@ Deprecated or removed
698713
* The keyword `immutable` is fully deprecated to `struct`, and
699714
`type` is fully deprecated to `mutable struct` ([#19157], [#20418]).
700715

716+
* `lufact`, `schurfact`, `lqfact`, `qrfact`, `ldltfact`, `svdfact`,
717+
`bkfact`, `hessfact`, `eigfact`, and `cholfact` have respectively been
718+
deprecated to `lu`, `schur`, `lq`, `qr`, `ldlt`, `svd`, `bunchkaufman`,
719+
`hessenberg`, `eigen`, and `cholesky` ([#26997], [#27159], [#27212]).
720+
721+
* `lufact!`, `schurfact!`, `lqfact!`, `qrfact!`, `ldltfact!`, `svdfact!`,
722+
`bkfact!`, `hessfact!`, and `eigfact!` have respectively been deprecated to
723+
`lu!`, `schur!`, `lq!`, `qr!`, `ldlt!`, `svd!`, `bunchkaufman!`,
724+
`hessenberg!`, and `eigen!` ([#26997], [#27159], [#27212]).
725+
726+
* `eig(A[, args...])` has been deprecated in favor of `eigen(A[, args...])`.
727+
Whereas the former returns a tuple of arrays, the latter returns an `Eigen` object.
728+
So for a direct replacement, use `(eigen(A[, args...])...,)`. But going forward,
729+
consider using the direct result of `eigen(A[, args...])` instead, either
730+
destructured into its components (`vals, vecs = eigen(A[, args...])`) or
731+
as an `Eigen` object (`X = eigen(A[, args...])`) ([#26997], [#27159], [#27212]).
732+
733+
* `eig(A::AbstractMatrix, B::AbstractMatrix)` and `eig(A::Number, B::Number)`
734+
have been deprecated in favor of `eigen(A, B)`. Whereas the former each return
735+
a tuple of arrays, the latter returns a `GeneralizedEigen` object. So for a direct
736+
replacement, use `(eigen(A, B)...,)`. But going forward, consider using the
737+
direct result of `eigen(A, B)` instead, either destructured into its components
738+
(`vals, vecs = eigen(A, B)`), or as a `GeneralizedEigen` object
739+
(`X = eigen(A, B)`) ([#26997], [#27159], [#27212]).
740+
701741
* Indexing into multidimensional arrays with more than one index but fewer indices than there are
702742
dimensions is no longer permitted when those trailing dimensions have lengths greater than 1.
703743
Instead, reshape the array or add trailing indices so the dimensionality and number of indices

doc/src/manual/arrays.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -746,37 +746,37 @@ creating any temporaries, and by calling the appropriate LAPACK function with th
746746
dimension size and stride parameters.
747747

748748
```julia-repl
749-
julia> a = rand(10,10)
749+
julia> a = rand(10, 10)
750750
10×10 Array{Float64,2}:
751-
0.561255 0.226678 0.203391 0.308912 … 0.750307 0.235023 0.217964
752-
0.718915 0.537192 0.556946 0.996234 0.666232 0.509423 0.660788
753-
0.493501 0.0565622 0.118392 0.493498 0.262048 0.940693 0.252965
754-
0.0470779 0.736979 0.264822 0.228787 0.161441 0.897023 0.567641
755-
0.343935 0.32327 0.795673 0.452242 0.468819 0.628507 0.511528
756-
0.935597 0.991511 0.571297 0.74485 … 0.84589 0.178834 0.284413
757-
0.160706 0.672252 0.133158 0.65554 0.371826 0.770628 0.0531208
758-
0.306617 0.836126 0.301198 0.0224702 0.39344 0.0370205 0.536062
759-
0.890947 0.168877 0.32002 0.486136 0.096078 0.172048 0.77672
760-
0.507762 0.573567 0.220124 0.165816 0.211049 0.433277 0.539476
751+
0.517515 0.0348206 0.749042 0.0979679 … 0.75984 0.950481 0.579513
752+
0.901092 0.873479 0.134533 0.0697848 0.0586695 0.193254 0.726898
753+
0.976808 0.0901881 0.208332 0.920358 0.288535 0.705941 0.337137
754+
0.657127 0.0317896 0.772837 0.534457 0.0966037 0.700694 0.675999
755+
0.471777 0.144969 0.0718405 0.0827916 0.527233 0.173132 0.694304
756+
0.160872 0.455168 0.489254 0.827851 … 0.62226 0.0995456 0.946522
757+
0.291857 0.769492 0.68043 0.629461 0.727558 0.910796 0.834837
758+
0.775774 0.700731 0.700177 0.0126213 0.00822304 0.327502 0.955181
759+
0.9715 0.64354 0.848441 0.241474 0.591611 0.792573 0.194357
760+
0.646596 0.575456 0.0995212 0.038517 0.709233 0.477657 0.0507231
761761
762762
julia> b = view(a, 2:2:8,2:2:4)
763-
4×2 SubArray{Float64,2,Array{Float64,2},Tuple{StepRange{Int64,Int64},StepRange{Int64,Int64}},false}:
764-
0.537192 0.996234
765-
0.736979 0.228787
766-
0.991511 0.74485
767-
0.836126 0.0224702
763+
4×2 view(::Array{Float64,2}, 2:2:8, 2:2:4) with eltype Float64:
764+
0.873479 0.0697848
765+
0.0317896 0.534457
766+
0.455168 0.827851
767+
0.700731 0.0126213
768768
769-
julia> (q,r) = qr(b);
769+
julia> (q, r) = qr(b);
770770
771771
julia> q
772-
2 Array{Float64,2}:
773-
-0.338809 0.78934
774-
-0.464815 -0.230274
775-
-0.625349 0.194538
776-
-0.527347 -0.534856
772+
4 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
773+
-0.722358 0.227524 -0.247784 -0.604181
774+
-0.0262896 -0.575919 -0.804227 0.144377
775+
-0.376419 -0.75072 0.540177 -0.0541979
776+
-0.579497 0.230151 -0.00552346 0.781782
777777
778778
julia> r
779779
2×2 Array{Float64,2}:
780-
-1.58553 -0.921517
781-
0.0 0.866567
780+
-1.20921 -0.383393
781+
0.0 -0.910506
782782
```

doc/src/manual/parallel-computing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ we could compute the singular values of several large random matrices in paralle
457457
```julia-repl
458458
julia> M = Matrix{Float64}[rand(1000,1000) for i = 1:10];
459459
460-
julia> pmap(svd, M);
460+
julia> pmap(svdvals, M);
461461
```
462462

463463
Julia's [`pmap`](@ref) is designed for the case where each function call does a large amount
@@ -486,7 +486,7 @@ As an example, consider computing the singular values of matrices of different s
486486
```julia-repl
487487
julia> M = Matrix{Float64}[rand(800,800), rand(600,600), rand(800,800), rand(600,600)];
488488
489-
julia> pmap(svd, M);
489+
julia> pmap(svdvals, M);
490490
```
491491

492492
If one process handles both 800×800 matrices and another handles both 600×600 matrices, we will

doc/src/manual/performance-tips.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ function norm(A)
544544
if isa(A, Vector)
545545
return sqrt(real(dot(A,A)))
546546
elseif isa(A, Matrix)
547-
return maximum(svd(A)[2])
547+
return maximum(svdvals(A))
548548
else
549549
error("norm: invalid argument")
550550
end
@@ -555,7 +555,7 @@ This can be written more concisely and efficiently as:
555555

556556
```julia
557557
norm(x::Vector) = sqrt(real(dot(x,x)))
558-
norm(A::Matrix) = maximum(svd(A)[2])
558+
norm(A::Matrix) = maximum(svdvals(A))
559559
```
560560

561561
## Write "type-stable" functions

stdlib/Distributed/test/distributed_exec.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ end
576576
n = 10
577577
as = [rand(4,4) for i in 1:n]
578578
bs = deepcopy(as)
579-
cs = collect(Distributed.pgenerate(x->(sleep(rand()*0.1); svdfact(x)), bs))
580-
svdas = map(svdfact, as)
579+
cs = collect(Distributed.pgenerate(x->(sleep(rand()*0.1); svd(x)), bs))
580+
svdas = map(svd, as)
581581
for i in 1:n
582582
@test cs[i].U svdas[i].U
583583
@test cs[i].S svdas[i].S

stdlib/IterativeEigensolvers/src/IterativeEigensolvers.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function _eigs(A, B;
7878
sym = !iscmplx && issymmetric(A) && issymmetric(B)
7979
nevmax = sym ? n-1 : n-2
8080
if nevmax <= 0
81-
throw(ArgumentError("input matrix A is too small. Use eigfact instead."))
81+
throw(ArgumentError("input matrix A is too small. Use eigen instead."))
8282
end
8383
if nev > nevmax
8484
@warn "Adjusting nev from $nev to $nevmax"
@@ -317,10 +317,10 @@ function _svds(X; nsv::Int = 6, ritzvec::Bool = true, tol::Float64 = 0.0, maxite
317317
# left_sv = sqrt(2) * ex[2][ 1:size(X,1), ind ] .* sign.(ex[1][ind]')
318318
if size(X, 1) >= size(X, 2)
319319
V = ex[2]
320-
U = qr(rmul!(X*V, Diagonal(inv.(svals))))[1]
320+
U = Array(qr(rmul!(X*V, Diagonal(inv.(svals)))).Q)
321321
else
322322
U = ex[2]
323-
V = qr(rmul!(X'U, Diagonal(inv.(svals))))[1]
323+
V = Array(qr(rmul!(X'U, Diagonal(inv.(svals)))).Q)
324324
end
325325

326326
# right_sv = sqrt(2) * ex[2][ size(X,1)+1:end, ind ]

stdlib/IterativeEigensolvers/test/runtests.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ LinearAlgebra.A_mul_B!(rho2::StridedVector{T},Phi::CPM{T},rho::StridedVector{T})
152152

153153
let
154154
# Generate random isometry
155-
(Q,R) = qr(randn(100,50))
156-
Q = reshape(Q,(50,2,50))
155+
(Q, R) = qr(randn(100, 50))
156+
Q = reshape(Array(Q), (50, 2, 50))
157157
# Construct trace-preserving completely positive map from this
158158
Phi = CPM(copy(Q))
159159
(d,v,nconv,numiter,numop,resid) = eigs(Phi,nev=1,which=:LM)
@@ -189,16 +189,16 @@ end
189189
S2 = svd(Array(A))
190190

191191
## singular values match:
192-
@test S1[1].S S2[2][1:2]
192+
@test S1[1].S S2.S[1:2]
193193
@testset "singular vectors" begin
194194
## 1st left singular vector
195195
s1_left = sign(S1[1].U[3,1]) * S1[1].U[:,1]
196-
s2_left = sign(S2[1][3,1]) * S2[1][:,1]
196+
s2_left = sign(S2.U[3,1]) * S2.U[:,1]
197197
@test s1_left s2_left
198198

199199
## 1st right singular vector
200200
s1_right = sign(S1[1].V[3,1]) * S1[1].V[:,1]
201-
s2_right = sign(S2[3][3,1]) * S2[3][:,1]
201+
s2_right = sign(S2.V[3,1]) * S2.V[:,1]
202202
@test s1_right s2_right
203203
end
204204
# Issue number 10329
@@ -213,7 +213,7 @@ end
213213
end
214214
@testset "passing guess for Krylov vectors" begin
215215
S1 = svds(A, nsv = 2, v0=rand(eltype(A),size(A,2)))
216-
@test S1[1].S S2[2][1:2]
216+
@test S1[1].S S2.S[1:2]
217217
end
218218

219219
@test_throws ArgumentError svds(A,nsv=0)
@@ -227,7 +227,7 @@ end
227227
for j in 2:i
228228
d[j] = d[1]
229229
end
230-
A = qr(randn(rng, 20, 20))[1]*Diagonal(d)*qr(randn(rng, 20, 20))[1]
230+
A = qr(randn(rng, 20, 20)).Q*Diagonal(d)*qr(randn(rng, 20, 20)).Q
231231
@testset "Number of singular values: $j" for j in 2:6
232232
# Default size of subspace
233233
F = svds(A, nsv = j, v0 = v0)
@@ -251,21 +251,21 @@ end
251251
S2 = svd(Array(A))
252252

253253
## singular values match:
254-
@test S1[1].S S2[2][1:2]
254+
@test S1[1].S S2.S[1:2]
255255
@testset "singular vectors" begin
256256
## left singular vectors
257257
s1_left = abs.(S1[1].U[:,1:2])
258-
s2_left = abs.(S2[1][:,1:2])
258+
s2_left = abs.(S2.U[:,1:2])
259259
@test s1_left s2_left
260260

261261
## right singular vectors
262262
s1_right = abs.(S1[1].V[:,1:2])
263-
s2_right = abs.(S2[3][:,1:2])
263+
s2_right = abs.(S2.V[:,1:2])
264264
@test s1_right s2_right
265265
end
266266
@testset "passing guess for Krylov vectors" begin
267267
S1 = svds(A, nsv = 2, v0=rand(eltype(A),size(A,2)))
268-
@test S1[1].S S2[2][1:2]
268+
@test S1[1].S S2.S[1:2]
269269
end
270270

271271
@test_throws ArgumentError svds(A,nsv=0)

stdlib/LinearAlgebra/docs/src/index.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Legend:
198198

199199
### Matrix factorizations
200200

201-
| Matrix type | LAPACK | [`eig`](@ref) | [`eigvals`](@ref) | [`eigvecs`](@ref) | [`svd`](@ref) | [`svdvals`](@ref) |
201+
| Matrix type | LAPACK | [`eigen`](@ref) | [`eigvals`](@ref) | [`eigvecs`](@ref) | [`svd`](@ref) | [`svdvals`](@ref) |
202202
|:------------------------- |:------ |:------------- |:----------------- |:----------------- |:------------- |:----------------- |
203203
| [`Symmetric`](@ref) | SY | | ARI | | | |
204204
| [`Hermitian`](@ref) | HE | | ARI | | | |
@@ -312,47 +312,40 @@ LinearAlgebra.LowerTriangular
312312
LinearAlgebra.UpperTriangular
313313
LinearAlgebra.UniformScaling
314314
LinearAlgebra.lu
315-
LinearAlgebra.lufact
316-
LinearAlgebra.lufact!
315+
LinearAlgebra.lu!
317316
LinearAlgebra.chol
318-
LinearAlgebra.cholfact
319-
LinearAlgebra.cholfact!
317+
LinearAlgebra.cholesky
318+
LinearAlgebra.cholesky!
320319
LinearAlgebra.lowrankupdate
321320
LinearAlgebra.lowrankdowndate
322321
LinearAlgebra.lowrankupdate!
323322
LinearAlgebra.lowrankdowndate!
324-
LinearAlgebra.ldltfact
325-
LinearAlgebra.ldltfact!
323+
LinearAlgebra.ldlt
324+
LinearAlgebra.ldlt!
326325
LinearAlgebra.qr
327326
LinearAlgebra.qr!
328-
LinearAlgebra.qrfact
329-
LinearAlgebra.qrfact!
330327
LinearAlgebra.QR
331328
LinearAlgebra.QRCompactWY
332329
LinearAlgebra.QRPivoted
333-
LinearAlgebra.lqfact!
334-
LinearAlgebra.lqfact
330+
LinearAlgebra.lq!
335331
LinearAlgebra.lq
336-
LinearAlgebra.bkfact
337-
LinearAlgebra.bkfact!
338-
LinearAlgebra.eig
332+
LinearAlgebra.bunchkaufman
333+
LinearAlgebra.bunchkaufman!
339334
LinearAlgebra.eigvals
340335
LinearAlgebra.eigvals!
341336
LinearAlgebra.eigmax
342337
LinearAlgebra.eigmin
343338
LinearAlgebra.eigvecs
344-
LinearAlgebra.eigfact
345-
LinearAlgebra.eigfact!
346-
LinearAlgebra.hessfact
347-
LinearAlgebra.hessfact!
348-
LinearAlgebra.schurfact
349-
LinearAlgebra.schurfact!
339+
LinearAlgebra.eigen
340+
LinearAlgebra.eigen!
341+
LinearAlgebra.hessenberg
342+
LinearAlgebra.hessenberg!
343+
LinearAlgebra.schur!
350344
LinearAlgebra.schur
351345
LinearAlgebra.ordschur
352346
LinearAlgebra.ordschur!
353-
LinearAlgebra.svdfact
354-
LinearAlgebra.svdfact!
355347
LinearAlgebra.svd
348+
LinearAlgebra.svd!
356349
LinearAlgebra.svdvals
357350
LinearAlgebra.svdvals!
358351
LinearAlgebra.Givens

0 commit comments

Comments
 (0)