Skip to content

Commit

Permalink
Merge branch 'master' into sgj/evalpoly
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah authored Feb 2, 2025
2 parents 1b43a2e + 443aa0f commit e051033
Show file tree
Hide file tree
Showing 18 changed files with 872 additions and 740 deletions.
48 changes: 23 additions & 25 deletions .ci/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version = "1.11.0"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.2.0+0"
version = "1.3.0+1"

[[deps.Dates]]
deps = ["Printf"]
Expand Down Expand Up @@ -52,7 +52,7 @@ version = "1.11.0"

[[deps.JuliaSyntaxHighlighting]]
deps = ["StyledStrings"]
uuid = "dc6e5ff7-fb65-4e79-a425-ec3bc9c03011"
uuid = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011"
version = "1.12.0"

[[deps.LazyArtifacts]]
Expand All @@ -66,24 +66,24 @@ uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.4"

[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "8.6.0+0"
version = "8.11.1+1"

[[deps.LibGit2]]
deps = ["LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
version = "1.11.0"

[[deps.LibGit2_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll"]
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
version = "1.8.0+0"
version = "1.9.0+0"

[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
deps = ["Artifacts", "Libdl", "OpenSSL_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.11.0+1"
version = "1.11.3+1"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand All @@ -93,7 +93,7 @@ version = "1.11.0"
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
path = ".."
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
version = "1.11.0"
version = "1.12.0"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand All @@ -104,31 +104,29 @@ deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
version = "1.11.0"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.6+1"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2024.3.11"
version = "2024.12.31"

[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"
version = "1.3.0"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.28+3"
version = "0.3.29+0"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "3.0.15+2"

[[deps.PackageCompiler]]
deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "RelocatableFolders", "TOML", "UUIDs", "p7zip_jll"]
git-tree-sha1 = "946623a388d8cb5874a0e2cb062dbbcfbb90cea5"
repo-rev = "kc/artifacts"
repo-url = "https://github.com/JuliaLang/PackageCompiler.jl.git"
git-tree-sha1 = "5d13e5b70011762b74f86fc08385303589f80272"
uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
version = "2.1.24"
version = "2.2.0"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"]
Expand Down Expand Up @@ -206,19 +204,19 @@ version = "1.11.0"
[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.3.1+1"
version = "1.3.1+2"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.11.2+0"
version = "5.12.0+0"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.63.0+1"
version = "1.64.0+1"

[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "17.5.0+1"
version = "17.5.0+2"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LinearAlgebra"
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
version = "1.11.0"
version = "1.12.0"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand Down
17 changes: 12 additions & 5 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1587,24 +1587,25 @@ factorize(A::Transpose) = transpose(factorize(parent(A)))
factorize(a::Number) = a # same as how factorize behaves on Diagonal types

function getstructure(A::StridedMatrix)
require_one_based_indexing(A)
m, n = size(A)
if m == 1 return A[1] end
utri = true
utri1 = true
herm = true
sym = true
for j = 1:n-1, i = j+1:m
if utri1
for j = 1:n, i = j:m
if (j < n) && (i > j) && utri1 # indices are off-diagonal
if A[i,j] != 0
utri1 = i == j + 1
utri = false
end
end
if sym
sym &= A[i,j] == A[j,i]
sym &= A[i,j] == transpose(A[j,i])
end
if herm
herm &= A[i,j] == conj(A[j,i])
herm &= A[i,j] == adjoint(A[j,i])
end
if !(utri1|herm|sym) break end
end
Expand All @@ -1617,10 +1618,12 @@ function getstructure(A::StridedMatrix)
if ltri1
for i = 1:n-1
if A[i,i+1] != 0
ltri &= false
ltri = false
break
end
end
else
ltri = false
end
return (utri, utri1, ltri, ltri1, sym, herm)
end
Expand Down Expand Up @@ -1779,6 +1782,10 @@ Condition number of the matrix `M`, computed using the operator `p`-norm. Valid
"""
function cond(A::AbstractMatrix, p::Real=2)
if p == 2
if isempty(A)
checksquare(A)
return zero(real(eigtype(eltype(A))))
end
v = svdvals(A)
maxv = maximum(v)
return iszero(maxv) ? oftype(real(maxv), Inf) : maxv / minimum(v)
Expand Down
24 changes: 13 additions & 11 deletions src/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2975,10 +2975,10 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in
mA = size(A, 1)
k = length(tau)
if side == 'L' && m != mA
throw(DimensionMismatch(lazy"for a left-sided multiplication, the first dimension of C, $m, must equal the second dimension of A, $mA"))
throw(DimensionMismatch(lazy"for a left-sided multiplication, the first dimension of C, $m, must equal the first dimension of A, $mA"))
end
if side == 'R' && n != mA
throw(DimensionMismatch(lazy"for a right-sided multiplication, the second dimension of C, $m, must equal the second dimension of A, $mA"))
throw(DimensionMismatch(lazy"for a right-sided multiplication, the second dimension of C, $n, must equal the first dimension of A, $mA"))
end
if side == 'L' && k > m
throw(DimensionMismatch(lazy"invalid number of reflectors: k = $k should be <= m = $m"))
Expand Down Expand Up @@ -3025,10 +3025,10 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in
mA = size(A, 1)
k = length(tau)
if side == 'L' && m != mA
throw(DimensionMismatch(lazy"for a left-sided multiplication, the first dimension of C, $m, must equal the second dimension of A, $mA"))
throw(DimensionMismatch(lazy"for a left-sided multiplication, the first dimension of C, $m, must equal the first dimension of A, $mA"))
end
if side == 'R' && n != mA
throw(DimensionMismatch(lazy"for a right-sided multiplication, the second dimension of C, $m, must equal the second dimension of A, $mA"))
throw(DimensionMismatch(lazy"for a right-sided multiplication, the second dimension of C, $n, must equal the first dimension of A, $mA"))
end
if side == 'L' && k > m
throw(DimensionMismatch(lazy"invalid number of reflectors: k = $k should be <= m = $m"))
Expand Down Expand Up @@ -3078,7 +3078,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in
throw(DimensionMismatch(lazy"for a left-sided multiplication, the first dimension of C, $m, must equal the second dimension of A, $nA"))
end
if side == 'R' && n != nA
throw(DimensionMismatch(lazy"for a right-sided multiplication, the second dimension of C, $m, must equal the second dimension of A, $nA"))
throw(DimensionMismatch(lazy"for a right-sided multiplication, the second dimension of C, $n, must equal the second dimension of A, $nA"))
end
if side == 'L' && k > m
throw(DimensionMismatch(lazy"invalid number of reflectors: k = $k should be <= m = $m"))
Expand Down Expand Up @@ -5391,9 +5391,9 @@ for (syev, syevr, syevd, sygvd, elty) in
W = similar(A, $elty, n)
ldz = n
if jobz == 'N'
Z = similar(A, $elty, ldz, 0)
Z = similar(A, $elty, 0)
elseif jobz == 'V'
Z = similar(A, $elty, ldz, n)
Z = similar(A, $elty, ldz * n)
end
isuppz = similar(A, BlasInt, 2*n)
work = Vector{$elty}(undef, 1)
Expand Down Expand Up @@ -5423,7 +5423,8 @@ for (syev, syevr, syevd, sygvd, elty) in
resize!(iwork, liwork)
end
end
W[1:m[]], Z[:,1:(jobz == 'V' ? m[] : 0)]
zm = jobz == 'V' ? m[] : 0
resize!(W, m[]), reshape(resize!(Z, ldz * zm), ldz, zm)
end
syevr!(jobz::AbstractChar, A::AbstractMatrix{$elty}) =
syevr!(jobz, 'A', 'U', A, 0.0, 0.0, 0, 0, -1.0)
Expand Down Expand Up @@ -5593,10 +5594,10 @@ for (syev, syevr, syevd, sygvd, elty, relty) in
W = similar(A, $relty, n)
if jobz == 'N'
ldz = 1
Z = similar(A, $elty, ldz, 0)
Z = similar(A, $elty, 0)
elseif jobz == 'V'
ldz = n
Z = similar(A, $elty, ldz, n)
Z = similar(A, $elty, ldz * n)
end
isuppz = similar(A, BlasInt, 2*n)
work = Vector{$elty}(undef, 1)
Expand Down Expand Up @@ -5632,7 +5633,8 @@ for (syev, syevr, syevd, sygvd, elty, relty) in
resize!(iwork, liwork)
end
end
W[1:m[]], Z[:,1:(jobz == 'V' ? m[] : 0)]
zm = jobz == 'V' ? m[] : 0
resize!(W, m[]), reshape(resize!(Z, ldz * zm), ldz, zm)
end
syevr!(jobz::AbstractChar, A::AbstractMatrix{$elty}) =
syevr!(jobz, 'A', 'U', A, 0.0, 0.0, 0, 0, -1.0)
Expand Down
38 changes: 16 additions & 22 deletions test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ using LinearAlgebra: BlasReal, BlasFloat

const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")

isdefined(Main, :Furlongs) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "Furlongs.jl"))
using .Main.Furlongs

isdefined(Main, :Quaternions) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "Quaternions.jl"))
using .Main.Quaternions

Expand Down Expand Up @@ -354,36 +351,33 @@ Random.seed!(1)
@test norm(x-tx,Inf) <= 4*condT*max(eps()*norm(tx,Inf), eps(promty)*norm(x,Inf))
end
@testset "Specialized multiplication/division" begin
getval(x) = x
getval(x::Furlong) = x.val
function _bidiagdivmultest(T,
x,
typemul=T.uplo == 'U' ? UpperTriangular : Matrix,
typediv=T.uplo == 'U' ? UpperTriangular : Matrix,
typediv2=T.uplo == 'U' ? UpperTriangular : Matrix)
TM = Matrix(T)
@test map(getval, (T*x)::typemul) map(getval, TM*x)
@test map(getval, (x*T)::typemul) map(getval, x*TM)
@test map(getval, (x\T)::typediv) map(getval, x\TM)
@test map(getval, (T/x)::typediv) map(getval, TM/x)
@test (T*x)::typemul TM*x
@test (x*T)::typemul x*TM
@test (x\T)::typediv x\TM
@test (T/x)::typediv TM/x
if !isa(x, Number)
@test map(getval, Array((T\x)::typediv2)) map(getval, Array(TM\x))
@test map(getval, Array((x/T)::typediv2)) map(getval, Array(x/TM))
@test Array((T\x)::typediv2) Array(TM\x)
@test Array((x/T)::typediv2) Array(x/TM)
end
return nothing
end
A = Matrix(T)
for t in (T, Furlong.(T)), (A, dv, ev) in ((A, dv, ev), (Furlong.(A), Furlong.(dv), Furlong.(ev)))
_bidiagdivmultest(t, 5, Bidiagonal, Bidiagonal)
_bidiagdivmultest(t, 5I, Bidiagonal, Bidiagonal, t.uplo == 'U' ? UpperTriangular : LowerTriangular)
_bidiagdivmultest(t, Diagonal(dv), Bidiagonal, Bidiagonal, t.uplo == 'U' ? UpperTriangular : LowerTriangular)
_bidiagdivmultest(t, UpperTriangular(A))
_bidiagdivmultest(t, UnitUpperTriangular(A))
_bidiagdivmultest(t, LowerTriangular(A), t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix)
_bidiagdivmultest(t, UnitLowerTriangular(A), t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix)
_bidiagdivmultest(t, Bidiagonal(dv, ev, :U), Matrix, Matrix, Matrix)
_bidiagdivmultest(t, Bidiagonal(dv, ev, :L), Matrix, Matrix, Matrix)
end
t = T
_bidiagdivmultest(t, 5, Bidiagonal, Bidiagonal)
_bidiagdivmultest(t, 5I, Bidiagonal, Bidiagonal, t.uplo == 'U' ? UpperTriangular : LowerTriangular)
_bidiagdivmultest(t, Diagonal(dv), Bidiagonal, Bidiagonal, t.uplo == 'U' ? UpperTriangular : LowerTriangular)
_bidiagdivmultest(t, UpperTriangular(A))
_bidiagdivmultest(t, UnitUpperTriangular(A))
_bidiagdivmultest(t, LowerTriangular(A), t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix)
_bidiagdivmultest(t, UnitLowerTriangular(A), t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix, t.uplo == 'L' ? LowerTriangular : Matrix)
_bidiagdivmultest(t, Bidiagonal(dv, ev, :U), Matrix, Matrix, Matrix)
_bidiagdivmultest(t, Bidiagonal(dv, ev, :L), Matrix, Matrix, Matrix)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ end
# Make sure we can use `Base.libblas_name`. Avoid causing
# https://github.com/JuliaLang/julia/issues/48427 again.
@testset "libblas_name" begin
dot_sym = dlsym(dlopen(Base.libblas_name), "cblas_ddot" * (Sys.WORD_SIZE == 64 ? "64_" : ""))
dot_sym = dlsym(dlopen(BLAS.libblastrampoline), "cblas_ddot" * (Sys.WORD_SIZE == 64 ? "64_" : ""))
@test 23.0 === @ccall $(dot_sym)(2::Int, [2.0, 3.0]::Ref{Cdouble}, 1::Int, [4.0, 5.0]::Ref{Cdouble}, 1::Int)::Cdouble
end

Expand Down
19 changes: 19 additions & 0 deletions test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ Random.seed!(1234323)
@test cond(Mars, 2) 6.181867355918493
@test cond(Mars, Inf) 7.1
end
@testset "Empty matrices" begin
for p in (1,2,Inf)
# zero for square (i.e. 0×0) matrices
@test cond(zeros(Int, 0, 0), p) === 0.0
@test cond(zeros(0, 0), p) === 0.0
@test cond(zeros(ComplexF64, 0, 0), p) === 0.0
# error for non-square matrices
for size in ((10,0), (0,10))
@test_throws DimensionMismatch cond(zeros(size...), p)
end
end
end
end

areal = randn(n,n)/2
Expand Down Expand Up @@ -1347,4 +1359,11 @@ end
end
end

@testset "structure of dense matrices" begin
# A is neither triangular nor symmetric/Hermitian
A = [1 im 2; -im 0 3; 2 3 im]
@test factorize(A) isa LU{ComplexF64, Matrix{ComplexF64}, Vector{Int}}
@test !any(LinearAlgebra.getstructure(A))
end

end # module TestDense
Loading

0 comments on commit e051033

Please sign in to comment.