Skip to content

Commit

Permalink
Merge branch 'main' into jishnub/sub2ind
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah authored Oct 10, 2023
2 parents e38d0ef + e86b148 commit 0711c40
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 50,125 deletions.
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "1"
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ makedocs(
"SparseArrays" => "index.md",
"Sparse Linear Algebra" => "solvers.md",
];
# strict = true,
strict = Symbol[:doctest],
warnonly = [:missing_docs, :cross_references],
)

deploydocs(repo = "github.com/JuliaSparse/SparseArrays.jl.git")
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ julia> R = sparsevec(I,V)
```

The inverse of the [`sparse`](@ref) and [`sparsevec`](@ref) functions is
[`findnz`](@ref), which retrieves the inputs used to create the sparse array.
[`findnz`](@ref), which retrieves the inputs used to create the sparse array (including stored entries equal to zero).
[`findall(!iszero, x)`](@ref) returns the Cartesian indices of non-zero entries in `x`
(including stored entries equal to zero).
(not including stored entries equal to zero).

```jldoctest sparse_function
julia> findnz(S)
Expand Down
5 changes: 4 additions & 1 deletion docs/src/solvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ Sparse matrix solvers call functions from [SuiteSparse](http://suitesparse.com).

Other solvers such as [Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl/) are available as external packages. [Arpack.jl](https://julialinearalgebra.github.io/Arpack.jl/stable/) provides `eigs` and `svds` for iterative solution of eigensystems and singular value decompositions.

These factorizations are described in more detail in [`Linear Algebra`](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/) section of the manual:
These factorizations are described in more detail in the
[`Linear Algebra`](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/)
section of the manual:

1. [`cholesky`](@ref SparseArrays.CHOLMOD.cholesky)
2. [`ldlt`](@ref SparseArrays.CHOLMOD.ldlt)
3. [`lu`](@ref SparseArrays.UMFPACK.lu)
Expand Down
26 changes: 12 additions & 14 deletions gen/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@ umfpack_h = joinpath(include_dir, "umfpack.h")
# load common option
options = load_options(joinpath(@__DIR__, "generator.toml"))

# run generator for all platforms
for target in JLLEnvs.JLL_ENV_TRIPLES
@info "processing $target"
# we only generate a single wrapper for all platforms, because the headers are currently not
# platform dependent. since this package is part of the default Julia distribution, we also
# need to make sure that it can handle all platforms, including new ones that are not yet
# supported by BinaryBuilder (the easiest solution here is to always use a single wrapper).
options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "src/solvers/wrappers.jl")
args = get_default_args()
push!(args, "-I$include_dir")

options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "src/solvers/lib", "$target.jl")
header_files = [cholmod_h, SuiteSparseQR_C_h, umfpack_h]

args = get_default_args(target)
push!(args, "-I$include_dir")
ctx = create_context(header_files, args, options)

header_files = [cholmod_h, SuiteSparseQR_C_h, umfpack_h]
build!(ctx)

ctx = create_context(header_files, args, options)

build!(ctx)

path = options["general"]["output_file_path"]
format_file(path, YASStyle())
end
path = options["general"]["output_file_path"]
format_file(path, YASStyle())
33 changes: 1 addition & 32 deletions src/solvers/LibSuiteSparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,7 @@ using SuiteSparse_jll
const TRUE = Int32(1)
const FALSE = Int32(0)

const IS_LIBC_MUSL = occursin("musl", Base.BUILD_TRIPLET)
if Sys.isapple() && Sys.ARCH === :aarch64
include("lib/aarch64-apple-darwin20.jl")
elseif Sys.islinux() && Sys.ARCH === :aarch64 && !IS_LIBC_MUSL
include("lib/aarch64-linux-gnu.jl")
elseif Sys.islinux() && Sys.ARCH === :aarch64 && IS_LIBC_MUSL
include("lib/aarch64-linux-musl.jl")
elseif Sys.islinux() && startswith(string(Sys.ARCH), "arm") && !IS_LIBC_MUSL
include("lib/armv7l-linux-gnueabihf.jl")
elseif Sys.islinux() && startswith(string(Sys.ARCH), "arm") && IS_LIBC_MUSL
include("lib/armv7l-linux-musleabihf.jl")
elseif Sys.islinux() && Sys.ARCH === :i686 && !IS_LIBC_MUSL
include("lib/i686-linux-gnu.jl")
elseif Sys.islinux() && Sys.ARCH === :i686 && IS_LIBC_MUSL
include("lib/i686-linux-musl.jl")
elseif Sys.iswindows() && Sys.ARCH === :i686
include("lib/i686-w64-mingw32.jl")
elseif Sys.islinux() && Sys.ARCH === :powerpc64le
include("lib/powerpc64le-linux-gnu.jl")
elseif Sys.isapple() && Sys.ARCH === :x86_64
include("lib/x86_64-apple-darwin14.jl")
elseif Sys.islinux() && Sys.ARCH === :x86_64 && !IS_LIBC_MUSL
include("lib/x86_64-linux-gnu.jl")
elseif Sys.islinux() && Sys.ARCH === :x86_64 && IS_LIBC_MUSL
include("lib/x86_64-linux-musl.jl")
elseif Sys.isbsd() && !Sys.isapple()
include("lib/x86_64-unknown-freebsd.jl")
elseif Sys.iswindows() && Sys.ARCH === :x86_64
include("lib/x86_64-w64-mingw32.jl")
else
error("Unknown platform: $(Base.BUILD_TRIPLET)")
end
include("wrappers.jl")

# exports
const PREFIXES = ["cholmod_", "CHOLMOD_", "umfpack_"]
Expand Down
21 changes: 14 additions & 7 deletions src/solvers/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ using LinearAlgebra
using LinearAlgebra: RealHermSymComplexHerm, AdjOrTrans
import LinearAlgebra: (\), AdjointFactorization,
cholesky, cholesky!, det, diag, ishermitian, isposdef,
issuccess, issymmetric, ldlt, ldlt!, logdet, lowrankdowndate!
issuccess, issymmetric, ldlt, ldlt!, logdet,
lowrankdowndate, lowrankdowndate!, lowrankupdate, lowrankupdate!

using SparseArrays
using SparseArrays: getcolptr, AbstractSparseVecOrMat
Expand Down Expand Up @@ -1433,10 +1434,16 @@ true
[^DavisHager2009]: Davis, Timothy A., & Hager, W. W. (2009). Dynamic Supernodes in Sparse Cholesky Update/Downdate and Triangular Solves. ACM Trans. Math. Softw., 35(4). [doi:10.1145/1462173.1462176](https://doi.org/10.1145/1462173.1462176)
"""
cholesky(A::Union{SparseMatrixCSC{T}, SparseMatrixCSC{Complex{T}},
Symmetric{T, <:SparseMatrixCSC{T}},
Hermitian{Complex{T}, <:SparseMatrixCSC{Complex{T}}},
Hermitian{T, <:SparseMatrixCSC{T}}};
kws...) where {T<:Real} = cholesky(Sparse(A); kws...)
RealHermSymComplexHerm{T,<:SparseMatrixCSC}}; kws...) where {T<:Real} =
cholesky(Sparse(A); kws...)

LinearAlgebra._cholesky(A::Union{SparseMatrixCSC{T}, SparseMatrixCSC{Complex{T}},
RealHermSymComplexHerm{T,<:SparseMatrixCSC}};
kws...) where {T<:Real} = cholesky(A; kws...)
LinearAlgebra._cholesky(A::Union{SparseMatrixCSC{T}, SparseMatrixCSC{Complex{T}},
RealHermSymComplexHerm{T,<:SparseMatrixCSC}}, ::LinearAlgebra.PivotingStrategy;
kws...) where {T<:Real} =
error("Pivoting strategies are not supported for `SparseMatrixCSC`s")

function ldlt!(F::Factor{Tv}, A::Sparse{Tv};
shift::Real=0.0, check::Bool = true) where Tv
Expand Down Expand Up @@ -1548,7 +1555,7 @@ factor will be `L*L' == P*A*P' + C'*C`
`update`: `Cint(1)` for `A + CC'`, `Cint(0)` for `A - CC'`
"""
lowrankdowndate!
lowrankupdowndate!

#Helper functions for rank updates
lowrank_reorder(V::AbstractArray,p) = Sparse(sparse(V[p,:]))
Expand Down Expand Up @@ -1597,7 +1604,7 @@ lowrankupdate(F::Factor{Tv}, V::AbstractArray{Tv}) where {Tv<:VTypes} =
lowrankupdate!(copy(F), V)

"""
lowrankupdate(F::CHOLMOD.Factor, C::AbstractArray) -> FF::CHOLMOD.Factor
lowrankdowndate(F::CHOLMOD.Factor, C::AbstractArray) -> FF::CHOLMOD.Factor
Get an `LDLt` Factorization of `A + C*C'` given an `LDLt` or `LLt` factorization `F` of `A`.
Expand Down
Loading

0 comments on commit 0711c40

Please sign in to comment.