Reference

BlockSparseArrays.BlockSparseArrayType
BlockSparseArray{T}(undef, dims)
BlockSparseArray{T,N}(undef, dims)
BlockSparseArray{T,N,A}(undef, dims)

Construct an uninitialized N-dimensional BlockSparseArray containing elements of type T. dims should be a list of block lengths in each dimension or a list of blocked ranges representing the axes.

source
BlockSparseArrays.SVDType
SVD <: Factorization

Matrix factorization type of the singular value decomposition (SVD) of a matrix A. This is the return type of svd(_), the corresponding matrix factorization function.

If F::SVD is the factorization object, U, S, V and Vt can be obtained via F.U, F.S, F.V and F.Vt, such that A = U * Diagonal(S) * Vt. The singular values in S are sorted in descending order.

Iterating the decomposition produces the components U, S, and V.

Examples

julia> A = [1. 0. 0. 0. 2.; 0. 0. 3. 0. 0.; 0. 0. 0. 0. 0.; 0. 2. 0. 0. 0.]
4×5 Matrix{Float64}:
 1.0  0.0  0.0  0.0  2.0
 0.0  0.0  3.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  2.0  0.0  0.0  0.0

julia> F = BlockSparseArrays.svd(A)
BlockSparseArrays.SVD{Float64, Float64, Matrix{Float64}, Vector{Float64}, Matrix{Float64}}
U factor:
4×4 Matrix{Float64}:
 0.0  1.0   0.0  0.0
 1.0  0.0   0.0  0.0
 0.0  0.0   0.0  1.0
 0.0  0.0  -1.0  0.0
singular values:
4-element Vector{Float64}:
 3.0
 2.23606797749979
 2.0
 0.0
Vt factor:
4×5 Matrix{Float64}:
 -0.0        0.0  1.0  -0.0  0.0
  0.447214   0.0  0.0   0.0  0.894427
  0.0       -1.0  0.0   0.0  0.0
  0.0        0.0  0.0   1.0  0.0

julia> F.U * Diagonal(F.S) * F.Vt
4×5 Matrix{Float64}:
 1.0  0.0  0.0  0.0  2.0
 0.0  0.0  3.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  2.0  0.0  0.0  0.0

julia> u, s, v = F; # destructuring via iteration

julia> u == F.U && s == F.S && v == F.V
true
source
SparseArraysBase.SparseArrayDOKMethod
SparseArrayDOK{T}(undef_blocks, axes)
SparseArrayDOK{T,N}(undef_blocks, axes)

Construct the block structure of an undefined BlockSparseArray that will have blocked axes axes.

Note that undef_blocks is defined in BlockArrays.jl and should be imported from that package to use it as an input to this constructor.

source
BlockSparseArrays.sparsemortarMethod
sparsemortar(blocks::AbstractArray{<:AbstractArray{T,N},N}, axes) -> ::BlockSparseArray{T,N}

Construct a block sparse array from a sparse array of arrays and specified blocked axes. The block sizes must be commensurate with the blocks of the axes.

source
BlockSparseArrays.svd!Method
svd!(A; full::Bool = false, alg::Algorithm = default_svd_alg(A)) -> SVD

svd! is the same as svd, but saves space by overwriting the input A, instead of creating a copy. See documentation of svd for details.

source
BlockSparseArrays.svdMethod
svd(A; full::Bool = false, alg::Algorithm = default_svd_alg(A)) -> SVD

Compute the singular value decomposition (SVD) of A and return an SVD object.

U, S, V and Vt can be obtained from the factorization F with F.U, F.S, F.V and F.Vt, such that A = U * Diagonal(S) * Vt. The algorithm produces Vt and hence Vt is more efficient to extract than V. The singular values in S are sorted in descending order.

Iterating the decomposition produces the components U, S, and V.

If full = false (default), a "thin" SVD is returned. For an $M \times N$ matrix A, in the full factorization U is $M \times M$ and V is $N \times N$, while in the thin factorization U is $M \times K$ and V is $N \times K$, where $K = \min(M,N)$ is the number of singular values.

alg specifies which algorithm and LAPACK method to use for SVD:

  • alg = DivideAndConquer() (default): Calls LAPACK.gesdd!.
  • alg = QRIteration(): Calls LAPACK.gesvd! (typically slower but more accurate) .
Julia 1.3

The alg keyword argument requires Julia 1.3 or later.

Examples

julia> A = rand(4,3);

julia> F = BlockSparseArrays.svd(A); # Store the Factorization Object

julia> A ≈ F.U * Diagonal(F.S) * F.Vt
true

julia> U, S, V = F; # destructuring via iteration

julia> A ≈ U * Diagonal(S) * V'
true

julia> Uonly, = BlockSparseArrays.svd(A); # Store U only

julia> Uonly == U
true
source