diff --git a/base/deprecated.jl b/base/deprecated.jl index 88c604a38d923..064d7cf6825c6 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1281,6 +1281,9 @@ export conv, conv2, deconv, filt, filt!, xcorr @eval @deprecate_moved $(Symbol("@dateformat_str")) "Dates" true true @deprecate_moved now "Dates" true true +@deprecate_moved eigs "Arnoldi" true true +@deprecate_moved svds "Arnoldi" true true + # PR #21709 @deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected) @deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected) diff --git a/base/exports.jl b/base/exports.jl index 275fc68be1c17..d72f39ffc8f04 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -555,7 +555,6 @@ export eigfact, eigmax, eigmin, - eigs, eigvals, eigvals!, eigvecs, @@ -602,7 +601,6 @@ export svd, svdfact!, svdfact, - svds, svdvals!, svdvals, sylvester, diff --git a/base/linalg/linalg.jl b/base/linalg/linalg.jl index a46682c8f354e..ce75dd49c4fc7 100644 --- a/base/linalg/linalg.jl +++ b/base/linalg/linalg.jl @@ -83,7 +83,6 @@ export eigfact!, eigmax, eigmin, - eigs, eigvals, eigvals!, eigvecs, @@ -131,7 +130,6 @@ export svd, svdfact!, svdfact, - svds, svdvals!, svdvals, sylvester, @@ -277,9 +275,6 @@ include("ldlt.jl") include("schur.jl") -include("arpack.jl") -include("arnoldi.jl") - function __init__() try BLAS.check() diff --git a/base/sparse/linalg.jl b/base/sparse/linalg.jl index cbdee2c69b99b..a1da22479f1ed 100644 --- a/base/sparse/linalg.jl +++ b/base/sparse/linalg.jl @@ -967,7 +967,7 @@ end chol(A::SparseMatrixCSC) = error("Use cholfact() instead of chol() for sparse matrices.") lu(A::SparseMatrixCSC) = error("Use lufact() instead of lu() for sparse matrices.") -eig(A::SparseMatrixCSC) = error("Use eigs() instead of eig() for sparse matrices.") +eig(A::SparseMatrixCSC) = error("Use Arnoldi.eigs() instead of eig() for sparse matrices.") function Base.cov(X::SparseMatrixCSC, vardim::Int=1; corrected::Bool=true) a, b = size(X) diff --git a/doc/make.jl b/doc/make.jl index bd02e1b0e59c1..a38eb45620565 100644 --- a/doc/make.jl +++ b/doc/make.jl @@ -30,6 +30,7 @@ if Sys.iswindows() cp_q("../stdlib/FileWatching/docs/src/index.md", "src/stdlib/filewatching.md") cp_q("../stdlib/CRC32c/docs/src/index.md", "src/stdlib/crc32c.md") cp_q("../stdlib/Dates/docs/src/index.md", "src/stdlib/dates.md") + cp_q("../stdlib/Arnoldi/docs/src/index.md", "src/stdlib/arnoldi.md") else symlink_q("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") symlink_q("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") @@ -40,6 +41,7 @@ else symlink_q("../../../stdlib/FileWatching/docs/src/index.md", "src/stdlib/filewatching.md") symlink_q("../../../stdlib/CRC32c/docs/src/index.md", "src/stdlib/crc32c.md") symlink_q("../../../stdlib/Dates/docs/src/index.md", "src/stdlib/dates.md") + symlink_q("../../../stdlib/Arnoldi/docs/src/index.md", "src/stdlib/arnoldi.md") end const PAGES = [ @@ -114,6 +116,7 @@ const PAGES = [ "stdlib/sharedarrays.md", "stdlib/filewatching.md", "stdlib/crc32c.md", + "stdlib/arnoldi.md", ], "Developer Documentation" => [ "devdocs/reflection.md", @@ -148,11 +151,13 @@ const PAGES = [ ], ] -using DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, CRC32c, Dates +using DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, CRC32c, + Dates, Arnoldi makedocs( build = joinpath(pwd(), "_build/html/en"), - modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, Dates], + modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile, + Base64, FileWatching, Dates, Arnoldi], clean = false, doctest = "doctest" in ARGS, linkcheck = "linkcheck" in ARGS, diff --git a/doc/src/index.md b/doc/src/index.md index 2c7fa3ae8c0dd..b9947f5b8a4a7 100644 --- a/doc/src/index.md +++ b/doc/src/index.md @@ -71,6 +71,7 @@ * [Shared Arrays](@ref) * [Base64](@ref) * [File Events](@ref lib-filewatching) + * [Arnoldi Iteration](@ref lib-arnoldi) ## Developer Documentation diff --git a/doc/src/stdlib/index.md b/doc/src/stdlib/index.md index be772c5f695e9..b2edebf6e96c5 100644 --- a/doc/src/stdlib/index.md +++ b/doc/src/stdlib/index.md @@ -29,3 +29,4 @@ * [Shared Arrays](@ref) * [Base64](@ref) * [File Events](@ref lib-filewatching) + * [Arnoldi Iteration](@ref lib-arnoldi) diff --git a/doc/src/stdlib/linalg.md b/doc/src/stdlib/linalg.md index cb2aa8236a566..b8c9fb13b8aec 100644 --- a/doc/src/stdlib/linalg.md +++ b/doc/src/stdlib/linalg.md @@ -136,9 +136,6 @@ Base.transpose Base.transpose! Base.adjoint Base.adjoint! -Base.LinAlg.eigs(::Any) -Base.LinAlg.eigs(::Any, ::Any) -Base.LinAlg.svds Base.LinAlg.peakflops Base.LinAlg.stride1 ``` diff --git a/stdlib/Arnoldi/docs/src/index.md b/stdlib/Arnoldi/docs/src/index.md new file mode 100644 index 0000000000000..c067e21c9a765 --- /dev/null +++ b/stdlib/Arnoldi/docs/src/index.md @@ -0,0 +1,7 @@ +# [Arnoldi Iteration](@id lib-arnoldi) + +```@docs +Arnoldi.eigs(::Any) +Arnoldi.eigs(::Any, ::Any) +Arnoldi.svds +``` diff --git a/base/linalg/arnoldi.jl b/stdlib/Arnoldi/src/Arnoldi.jl similarity index 96% rename from base/linalg/arnoldi.jl rename to stdlib/Arnoldi/src/Arnoldi.jl index fe05312d94f27..86e581579dda6 100644 --- a/base/linalg/arnoldi.jl +++ b/stdlib/Arnoldi/src/Arnoldi.jl @@ -1,5 +1,16 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +""" +Arnoldi and Lanczos iteration for computing eigenvalues +""" +module Arnoldi + +using Base.LinAlg: BlasFloat, BlasInt, SVD, checksquare + +export eigs, svds + +include("arpack.jl") + using .ARPACK ## eigs @@ -308,14 +319,14 @@ function SVDAugmented(A::AbstractMatrix{T}) where T SVDAugmented{Tnew,typeof(Anew)}(Anew) end -function A_mul_B!(y::StridedVector{T}, A::SVDAugmented{T}, x::StridedVector{T}) where T +function Base.A_mul_B!(y::StridedVector{T}, A::SVDAugmented{T}, x::StridedVector{T}) where T m, mn = size(A.X, 1), length(x) A_mul_B!( view(y, 1:m), A.X, view(x, m + 1:mn)) # left singular vector Ac_mul_B!(view(y, m + 1:mn), A.X, view(x, 1:m)) # right singular vector return y end -size(A::SVDAugmented) = ((+)(size(A.X)...), (+)(size(A.X)...)) -ishermitian(A::SVDAugmented) = true +Base.size(A::SVDAugmented) = ((+)(size(A.X)...), (+)(size(A.X)...)) +Base.ishermitian(A::SVDAugmented) = true struct AtA_or_AAt{T,S} <: AbstractArray{T, 2} A::S @@ -328,7 +339,7 @@ function AtA_or_AAt(A::AbstractMatrix{T}) where T AtA_or_AAt{Tnew,typeof(Anew)}(Anew, Vector{Tnew}(max(size(A)...))) end -function A_mul_B!(y::StridedVector{T}, A::AtA_or_AAt{T}, x::StridedVector{T}) where T +function Base.A_mul_B!(y::StridedVector{T}, A::AtA_or_AAt{T}, x::StridedVector{T}) where T if size(A.A, 1) >= size(A.A, 2) A_mul_B!(A.buffer, A.A, x) return Ac_mul_B!(y, A.A, A.buffer) @@ -337,8 +348,8 @@ function A_mul_B!(y::StridedVector{T}, A::AtA_or_AAt{T}, x::StridedVector{T}) wh return A_mul_B!(y, A.A, A.buffer) end end -size(A::AtA_or_AAt) = ntuple(i -> min(size(A.A)...), Val(2)) -ishermitian(s::AtA_or_AAt) = true +Base.size(A::AtA_or_AAt) = ntuple(i -> min(size(A.A)...), Val(2)) +Base.ishermitian(s::AtA_or_AAt) = true svds(A::AbstractMatrix{<:BlasFloat}; kwargs...) = _svds(A; kwargs...) @@ -433,3 +444,5 @@ function _svds(X; nsv::Int = 6, ritzvec::Bool = true, tol::Float64 = 0.0, maxite ex[2], ex[3], ex[4], ex[5]) end end + +end # module diff --git a/base/linalg/arpack.jl b/stdlib/Arnoldi/src/arpack.jl similarity index 100% rename from base/linalg/arpack.jl rename to stdlib/Arnoldi/src/arpack.jl diff --git a/test/linalg/arnoldi.jl b/stdlib/Arnoldi/test/runtests.jl similarity index 99% rename from test/linalg/arnoldi.jl rename to stdlib/Arnoldi/test/runtests.jl index 6678e1e3bdcdb..2f0ad6af39cd2 100644 --- a/test/linalg/arnoldi.jl +++ b/stdlib/Arnoldi/test/runtests.jl @@ -1,5 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +using Arnoldi using Test @testset "eigs" begin diff --git a/test/choosetests.jl b/test/choosetests.jl index e2196d2b3fbe5..6040edeba8d79 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -127,9 +127,6 @@ function choosetests(choices = []) "linalg/generic", "linalg/uniformscaling", "linalg/lq", "linalg/hessenberg", "linalg/rowvector", "linalg/conjarray", "linalg/blas"] - if Base.USE_GPL_LIBS - push!(linalgtests, "linalg/arnoldi") - end if "linalg" in skip_tests filter!(x -> (x != "linalg" && !(x in linalgtests)), tests) diff --git a/test/show.jl b/test/show.jl index 134fc4575afc3..3e97bfdbf24de 100644 --- a/test/show.jl +++ b/test/show.jl @@ -535,9 +535,9 @@ let repr = sprint(show, "text/html", methods(f16580)) end if isempty(Base.GIT_VERSION_INFO.commit) - @test contains(Base.url(first(methods(eigs))),"https://github.com/JuliaLang/julia/tree/v$VERSION/base/linalg/arnoldi.jl#L") + @test contains(Base.url(first(methods(sin))),"https://github.com/JuliaLang/julia/tree/v$VERSION/base/mpfr.jl#L") else - @test contains(Base.url(first(methods(eigs))),"https://github.com/JuliaLang/julia/tree/$(Base.GIT_VERSION_INFO.commit)/base/linalg/arnoldi.jl#L") + @test contains(Base.url(first(methods(sin))),"https://github.com/JuliaLang/julia/tree/$(Base.GIT_VERSION_INFO.commit)/base/mpfr.jl#L") end # print_matrix should be able to handle small and large objects easily, test by diff --git a/test/stdlib.jl b/test/stdlib.jl index 0c16c90220c0e..f0988555248fc 100644 --- a/test/stdlib.jl +++ b/test/stdlib.jl @@ -10,5 +10,6 @@ cd(joinpath(JULIA_HOME,"..","share","julia","site","v$(VERSION.major).$(VERSION. warn("Skipping Profile tests") filter!(x -> (x != "Profile"), pkgs) end + Base.USE_GPL_LIBS || filter!(x->x != "Arnoldi", pkgs) Pkg.Entry.test(convert(Vector{AbstractString}, pkgs)) end