References
Names that are neither exported nor declared public are internal, and may change without notice.
Base.Matrix — Method
Matrix(H::HMatrix)Convert H to a dense Matrix, in the ordering of the points used to assemble it.
HMatrices.AbstractCompressor — Type
abstract type AbstractCompressorTypes used to compress matrices. A compressor comp is called as comp(K, irange, jrange, buf) and returns an RkMatrix approximating K[irange, jrange], where buf is a workspace created by allocate_buffer(comp, T) (nothing by default). During the assembly of an HMatrix, it is called with the index ranges of each admissible block.
HMatrices.AbstractKernelMatrix — Type
abstract type AbstractKernelMatrix{T} <: AbstractMatrix{T}Interface for abstract matrices represented through a kernel function f, target elements X, and source elements Y. The matrix entry i,j is given by f(X[i],Y[j]). Concrete subtypes should implement Base.size, Base.getindex(K, i::Int, j::Int), and rowelements and colelements, whose elements have a center used to cluster them.
Implementing getblock! (e.g. with SIMD vectorization) can improve the speed of assembling an HMatrix.
HMatrices.AbstractSplitter — Type
abstract type AbstractSplitterAn AbstractSplitter is used to split a ClusterTree. The interface requires the following methods:
should_split(clt,depth,splitter): return aBooldetermining if theClusterTreeshould be further dividedsplit!(clt,splitter): perform the splitting of theClusterTreehandling the necessary data sorting.
See GeometricSplitter for an example of an implementation.
HMatrices.CardinalitySplitter — Type
struct CardinalitySplitter <: AbstractSplitterUsed to split a ClusterTree along the largest dimension if length(tree)>nmax. The split is performed so the data is evenly distributed amongst all children.
See also: AbstractSplitter
HMatrices.CarryTerm — Type
struct CarryTerm{T}Restriction of a LazyLowRankTerm to a block below the one it was computed for: its rows starting after row_offset, and its columns starting after col_offset, the size of the restriction being the one of this block.
HMatrices.ClusterTree — Type
ClusterTree(elements,splitter;[copy_elements=true, threads=false])Construct a ClusterTree from the given elements using the splitting strategy encoded in splitter. If copy_elements is set to false, the elements argument are directly stored in the ClusterTree and are permuted during the tree construction.
HMatrices.ClusterTree — Type
mutable struct ClusterTree{N,T}Tree structure used to cluster points of type SVector{N,T} into HyperRectangles.
Fields:
_elements::Vector{SVector{N,T}}: vector containing the sorted elements.container::HyperRectangle{N,T}: container for the elements in the current node.index_range::UnitRange{Int}: indices of elements contained in the current node.loc2glob::Vector{Int}: permutation from the local indexing system to the original (global) indexing system used as input in the construction of the tree.glob2loc::Vector{Int}: inverse ofloc2globpermutation.children::Vector{ClusterTree{N,T}}parentnode::ClusterTree{N,T}
HMatrices.ExecutorTask — Type
mutable struct ExecutorTaskA piece of work of a ThreadsExecutor, with the number of its unfinished dependencies (one more while it is being spawned, so that it does not run before), and the pieces of work depending on it. work === nothing for a join.
HMatrices.GeometricSplitter — Type
struct GeometricSplitter <: AbstractSplitterUsed to split a ClusterTree in half along the largest axis. The children boxes are shrunk to tightly fit the data.
HMatrices.HMatrix — Type
mutable struct HMatrix{R,T} <: AbstractMatrix{T}A hierarchical matrix constructed from a rowtree and coltree of type R and holding elements of type T.
HMatrices.HMatrix — Method
HMatrix{T}(rowtree,coltree,adm)Construct an empty HMatrix with rowtree and coltree using the admissibility condition adm. This function builds the skeleton for the hierarchical matrix, but does not compute data field in the blocks. See assemble_hmatrix for assembling a hierarchical matrix.
HMatrices.HyperRectangle — Type
struct HyperRectangle{N,T}Axis-aligned hyperrectangle in N dimensions given by low_corner::SVector{N,T} and high_corner::SVector{N,T}.
HMatrices.KernelMatrix — Type
KernelMatrix{Tf,Tx,Ty,T} <:: AbstractKernelMatrix{T}Generic kernel matrix representing a kernel function acting on two sets of elements. If K is a KernelMatrix, then K[i,j] = f(X[i],Y[j]) where f::Tf=kernel(K), X::Tx=rowelements(K) and Y::Ty=colelements(K).
Examples
X = rand(SVector{2,Float64},2)
Y = rand(SVector{2,Float64},2)
K = KernelMatrix(X,Y) do x,y
sum(x+y)
endHMatrices.LazyDriver — Type
struct LazyDriverState of an algorithm on an HMatrix where every update is deferred until the block it targets is factorized, solved for, or flushed (e.g. the lu! and cholesky! factorizations, hmul!), with its numeric work run by an executor (SerialExecutor or ThreadsExecutor).
By the block Crout identity, every block of the factors is determined by a single Schur complement, a sum of products of blocks of the factors that precede it. Instead of evaluating these products one at a time and recompressing after each one, each node carries the products it still owes, and the exact low-rank terms already evaluated for it (see PendingUpdates), representing the update C ← C + Σₖ AₖBₖ' + α*Σᵢ XᵢYᵢ. A node is flushed right before it is factorized or solved for (see flush!), so that every admissible leaf is compressed once, with comp. This is the accumulator of Börm (2019, "Hierarchical matrix arithmetic with accumulated updates"), except that an admissible leaf is compressed once from the whole sum.
The driver does the structural work (pushing and splitting products, restricting low-rank terms) itself, and hands the numeric work to executor: the low-rank terms of a node, the flush of a leaf, and the factorization of a diagonal leaf or the triangular solve on a leaf. A leaf is written by at most one flush followed by one factorization or solve, a low-rank term by one piece of work, and a block is only read once final, which is the access pattern of the executors. The workspaces of the pieces of work are taken from buffers.
With uplo = 'U' (or 'L'), only the upper (or lower) triangle of the diagonal blocks (whose rows and columns have the same indices) is updated, as for the data of a Hermitian; uplo = 'N' updates every block.
LazyDriver(C::HMatrix, X, Y, comp; α = -1, uplo = 'N', executor = SerialExecutor())A driver for the nodes of C (and of any HMatrix of the same type), with products of blocks of the types of X and Y (HMatrix or adjoint).
HMatrices.LazyLowRankTerm — Type
mutable struct LazyLowRankTerm{T}An exact low-rank term A*B' of the size of the block it was computed for: the product α*X*Y of two blocks of the factors, one of them being a leaf. One of A and B is usually a factor of this leaf (not a copy), the other one is computed.
It is computed by a piece of work (see _compute_low_rank_term), and read by the flushes of the leaves below the block (see LazyDriver), through restrictions (CarryTerm).
HMatrices.LeafOperator — Type
struct LeafOperator{T,M,V,S} <: AbstractMatrix{T}The operator
L = A * B' + α * ∑ᵢ Xᵢ * Yᵢknown through its rows and columns, or its products with blocks of vectors, where (A, B) are low-rank factors (of type M), (Xᵢ, Yᵢ) are pairs of hierarchical matrices (of type V), and α is a scalar. It is the value of an admissible leaf with its deferred updates, which a compressor compresses once (see _flush_low_rank_leaf!): compressor(L, axes(L)..., buf), through getblock! (see PartialACA), or mul! (see RandomizedSVD).
LeafOperator{T}(A, B, pairs, α, buffer = T[], rkbuffer = T[])The scratch vectors buffer and rkbuffer grow as needed, and can be reused (e.g. taken from the workspace of a flush).
HMatrices.PartialACA — Type
struct PartialACAAdaptive cross approximation algorithm with partial pivoting. This structure can be used to generate an RkMatrix from a matrix-like object M as follows:
using LinearAlgebra
using HMatrices: PartialACA
rtol = 1e-6
comp = PartialACA(;rtol)
A = rand(10,2)
B = rand(10,2)
M = A*adjoint(B) # a low-rank matrix
R = comp(M, axes(M)...) # compress the entire matrix `M`
norm(Matrix(R) - M) < rtol*norm(M) # true
# output
true
Because it uses partial pivoting, the linear operator does not have to be evaluated at every i,j. This is usually much faster than TSVD, but due to the pivoting strategy the algorithm may fail in special cases, even when the underlying linear operator is of low rank.
ACA estimates its error from the last cross only, which can stop it too early, or miss part of a block whose rows visited by ACA vanish on it (e.g. a double layer between two parallel sheets). Before stopping, it checks the residual at max(samples*k, 20) entries, where k is the current rank: half at pseudo-random positions, half in the rows and columns of the smallest norms in the factors, which the approximation leaves out; it continues from the largest residual if they show an error above the tolerance. samples = 0 disables this check, which is also skipped when an entry costs a whole column (in the products of the factorizations).
With recompress = true, the result is recompressed by a truncated SVD, computed from QR factorizations of its factors (see TSVD), with the same tolerances, which lowers its rank at the cost of a QR factorization of each factor and an SVD of a small matrix. In the factorizations, the lower ranks also make the later products cheaper.
The default rtol is sqrt(eps(R)), where R is the real type underlying the entries of the compressed matrix, or only the accuracy attainable with R if atol or rank is given. An rtol smaller than that accuracy (10eps(R)) is raised to it, or throws an ArgumentError if it is positive, so the rank of a block can stay below rank when the rest of the block is at the level of rounding errors.
HMatrices.PendingUpdates — Type
struct PendingUpdates{P,T}The updates pending at a node: the products (X, Y) (of type P) it still owes, and the exact low-rank terms already evaluated for it (the carry).
HMatrices.PermutedMatrix — Type
PermutedMatrix{K,T} <: AbstractMatrix{T}Structure used to represent the permutation of a matrix-like object. The original matrix is stored in the data::K field, and the permutations are stored in rowperm and colperm.
HMatrices.PrincipalComponentSplitter — Type
struct PrincipalComponentSplitter <: AbstractSplitterHMatrices.RandomizedSVD — Type
RandomizedSVD(; atol = 0, rank = typemax(Int), rtol = nothing, block = 4)Compression algorithm based on a randomized SVD (Halko, Martinsson and Tropp, "Finding structure with randomness", SIAM Review 53, 2011): an orthonormal basis Q of the range of the block M is given by the Householder QR factorization of the products of M with random Gaussian vectors, extended by blocks of block vectors until the error `|M
- QQ'M|
estimated from the last block is belowmax(atol, rtol*|M|)`, in the
Frobenius norm. The SVD of Q'*M is then truncated as by TSVD, and at most rank singular values are kept; with a rank, the basis has one more block than the rank, so that the singular values kept are accurate. The default rtol is the same as for PartialACA.
It only uses the products M*X and M'*X, whose evaluations are batched. It suits the blocks whose updates are deferred in the factorizations and the products: their products are cheap, while each of their entries costs a whole column. It is the default compressor of lu and cholesky. Any other block is first evaluated entirely, so PartialACA should be preferred for the assembly.
The error is estimated from the residuals of a single block of random vectors, which is more reliable for larger blocks. The random vectors only depend on the size of the block, so that the results are reproducible.
HMatrices.RkMatrix — Type
mutable struct RkMatrix{T}Representation of a rank r matrix M in outer product format M = A*adjoint(B) where A has size m × r and B has size n × r.
Two additional fields describe the factors, when this information is available:
orthogonality::Symbol: which factors have mutually orthogonal columns::none,:A,:B, or:AB(e.g. a truncated SVD,A = U*ΣandB = V).truncation_error::Vector{Float64}:truncation_error[i]is an estimate of the Frobenius norm of the error made by keeping only the firsticolumns of the factors (the last entry estimates the error ofRitself). It is exact (up to rounding) for a truncated SVD of an exact matrix, and an estimate otherwise (e.g. the error of aPartialACA, combined with the one of its recompression). An empty vector means that no estimate is available.
Constructing an RkMatrix from A and B only, or assigning R.A or R.B, resets these fields to :none and Float64[].
HMatrices.SerialExecutor — Type
SerialExecutor()Executor running every piece of work immediately, in the calling task: with executor = SerialExecutor(), the algorithms which take an executor (e.g. lu!, cholesky!) run sequentially, as with threads = false.
HMatrices.StrongAdmissibilityStd — Type
struct StrongAdmissibilityStdTwo blocks are admissible under this condition if the minimum of their diameter is smaller than eta times the distance between them, where eta::Float64 is a parameter.
Usage:
adm = StrongAdmissibilityStd(;eta=2.0)
adm(Xnode,Ynode)HMatrices.TSVD — Type
struct TSVDCompression algorithm based on a posteriori truncation of an SVD: the singular values σᵣ₊₁, σᵣ₊₂, … are dropped, for the smallest r such that the error of the truncation in the Frobenius norm, sqrt(σᵣ₊₁² + σᵣ₊₂² + ⋯), is at most max(atol, rtol*|M|), where |M| is the Frobenius norm of the matrix (the norm in which PartialACA estimates its error), and at most rank are kept. This is the best approximation of its rank. It evaluates every entry of the block, so it should be used mostly for "small" matrices. The default rtol is the same as for PartialACA.
HMatrices.ThreadsExecutor — Type
ThreadsExecutor(; check_accesses = false)Executor running pieces of work as tasks on Julia's threads, each one waiting only for the last piece of work which wrote each of the objects it reads or writes: with executor = ThreadsExecutor(), the algorithms which take an executor (e.g. lu!, cholesky!) run in parallel, as with threads = true. An error raised by a piece of work is rethrown as is, without the backtrace of its task; running sequentially (see SerialExecutor) gives the full backtrace.
spawn!(work, ex, reads, writes) registers work(), which reads the objects of reads and modifies those of writes, and wait(ex) returns once all the work spawned is done, then forgets it, and rethrows the first error of a piece of work.
There is no general dependency analysis: the executor only keeps the last writer of every object, which is enough for drivers satisfying the following access pattern:
- an object is written by a sequence of pieces of work, which are run in the order in which they are spawned;
- an object is only read once final, i.e. after its last write has been spawned, so that there are no write-after-read hazards.
The objects written are leaves of an HMatrix, or other objects (e.g. a low-rank term computed by one piece of work and read by others). A read of an internal block of an HMatrix is a read of all its leaves: it waits for a join over the last writers of its leaves, created at its first read and reused afterwards. With check_accesses = true, the executor checks this access pattern: that no object is written after it, or an internal block containing it, was read.
A piece of work never blocks: it counts its unfinished dependencies, and is spawned as a task by the piece of work completing the last of them. The objects are identified by their objectid, so that the executor does not keep them alive.
HMatrices.UpdateBuffer — Type
struct UpdateBuffer{B,T}Workspace of a flush: the buffer comp of the compressor, the storage lowrank of the packed low-rank factors of the leaf being compressed (see _flush_low_rank_leaf!), and two vectors scratch and rkscratch for intermediate products (those of a LeafOperator). The vectors grow as needed and are reused.
HMatrices.VectorOfVectors — Type
struct VectorOfVectors{T}A simple structure which behaves as a Vector{Vector{T}} but stores the entries in a contiguous data::Vector{T} field. All vectors in the VectorOfVectors are assumed to be of size m, and there are k of them, meaning this structure can be used to represent a m × k matrix.
Similar to a vector-of-vectors, calling A[i] returns a view to the i-th column.
See also: newcol!
HMatrices.WeakAdmissibilityStd — Type
struct WeakAdmissibilityStdTwo blocks are admissible under this condition if the distance between them is positive.
Base.push! — Method
push!(d::LazyDriver, C::HMatrix, X, Y)Register the update C ← C + α*X*Y (see LazyDriver), without performing any arithmetic. X and Y must not be modified afterwards: their data may be referenced (without copies) by the low-rank terms created when the update is applied.
Base.split — Method
split(rec::HyperRectangle,[axis]::Int,[place])Split a hyperrectangle in two along the axis direction at the position place. Returns a tuple with the two resulting hyperrectangles.
When no place is given, defaults to splitting in the middle of the axis.
When no axis and no place is given, defaults to splitting along the largest axis.
HMatrices._aca_partial — Function
_aca_partial(K, irange, jrange, atol, rmax, rtol, samples, buffer = nothing)Internal function implementing the adaptive cross-approximation algorithm with partial pivoting. The returned R::RkMatrix provides an approximation to M = K[irange,jrange] of rank at most rmax, which is expected to satisfy |M - R| < max(atol,rtol*|M|), but this inequality may fail to hold due to the various errors involved in estimating the error and |M|.
HMatrices._aca_partial_pivot — Method
_aca_partial_pivot(v,I)Find in the valid set I the index of the element x ∈ v maximizing its smallest singular value. This is equivalent to minimizing the spectral norm of the inverse of x.
When x is a scalar, this is simply the element with largest absolute value. Return -1 if I has no valid index.
This general implementation should work for both scalar as well as tensor-valued kernels; see https://www.sciencedirect.com/science/article/pii/S0021999117306721 for more details.
HMatrices._aca_residual_sample — Method
_aca_residual_sample(K, A, B, I, J, buffer, irange, jrange, ns, tol, r)Check the residual K[irange, jrange] - A*Bᴴ at ns entries, and return the unused row of the largest residual found if it shows an error above tol, and -1 otherwise.
Half of the entries are at pseudo-random positions, from which the Frobenius norm of the residual is estimated. The other half pair the unused rows of A and of B of the smallest norms (kept in buffer.ra and buffer.rb), which the approximation leaves out: an entry there more than 10 times above the average allowed by tol means that ACA missed part of the block.
HMatrices._aca_truncation_error — Method
_aca_truncation_error(steps)The estimated truncation errors of an ACA with rank-one updates of norms steps: keeping i updates leaves the next ones, and the error of the last update is estimated by its norm (the stopping criterion of the ACA).
HMatrices._add_dependency! — Method
_add_dependency!(task::ExecutorTask, dependency)Make task wait for dependency (an ExecutorTask, or nothing), unless it is done.
HMatrices._add_lowrank_col! — Method
_add_lowrank_col!(col, A, B, j, buf)col ← col + (A*B')[:, j], with the row j of B adjoined into the scratch vector buf, so that the product is a matrix-vector product with A (BLAS for numbers, which a view of adjoint(B) with complex entries does not reach).
HMatrices._assemble! — Method
_assemble!(hmat, K, comp, executor)Assemble the leaves of hmat, whose structure is already built, each by a piece of work of executor which writes it: the admissible leaves are compressed with comp, the others are evaluated.
HMatrices._block_matrix — Method
_block_matrix(S, M)The matrix with entries of type S made of the blocks of M, whose columns are padded with zeros to a multiple of the size of S.
HMatrices._build_block_structure! — Method
_build_block_structure!(adm_fun,current_node)Recursive constructor for HMatrix block structure. Should not be called directly.
HMatrices._can_sample — Method
_can_sample(K)Whether single entries of K are cheap, as needed by _aca_residual_sample.
HMatrices._check_rtol — Method
_check_rtol(comp, T)Check that the tolerances of comp are attainable for entries of type T, before compressing any block.
HMatrices._check_tolerances — Method
_check_tolerances(atol, rank, rtol)Throw an ArgumentError unless atol ≥ 0, rank ≥ 1 and rtol is nothing or ≥ 0; return them otherwise. Whether rtol is attainable depends on the entries, and is checked by _rtol.
HMatrices._check_write — Method
_check_write(ex::ThreadsExecutor, x)Throw an error if x, or an internal block of an HMatrix containing it, was already read: its readers would not wait for this write.
HMatrices._cholesky! — Method
_cholesky!(d::LazyDriver, M::HMatrix)Driver of cholesky! for the diagonal block M (whose upper triangle holds the data): flush M, then factor it (dense Cholesky of a leaf), or recurse on its children, solving for the blocks of the first block row and pushing the updates M[j,k] ← M[j,k] - M[i,j]'*M[i,k] of the upper triangle.
HMatrices._compute_low_rank_term — Function
_compute_low_rank_term(X, Y, α[, buf])Return factors (A, B) (matrices) such that α*X*Y = A*B', where X or Y (an HMatrix or its adjoint) is a low-rank leaf, or both are dense leaves (see _has_low_rank_form). The factorization is exact: its rank (see _low_rank_term_rank) is either the smallest rank of the low-rank factors, or the size of the cluster shared by X and Y, which is a leaf when X*Y targets an internal node. A factor of a low-rank leaf, or the dense data of X, is shared, not copied.
HMatrices._compute_low_rank_term! — Method
_compute_low_rank_term!(A, B, X, Y, α, buf)Like _compute_low_rank_term, but writing the factors into A and B (which may already be the factors shared with X or Y), using the scratch vector buf.
HMatrices._error_estimate — Method
_error_estimate(R::RkMatrix)The estimated error of R itself (zero if unknown).
HMatrices._execute! — Method
_execute!(ex::ThreadsExecutor, task::ExecutorTask)Run the work of task, recording its error if it throws, then release the pieces of work depending on it.
HMatrices._executor — Method
_executor(threads::Bool)The default executor: a ThreadsExecutor if threads and Julia runs on several threads, and a SerialExecutor otherwise.
HMatrices._flush_dense_leaf! — Method
_flush_dense_leaf!(C::HMatrix, updates::PendingUpdates, α)Add the carry and the products α*X*Y to the dense data of the leaf C.
HMatrices._flush_internal_node! — Method
_flush_internal_node!(d::LazyDriver, C::HMatrix, updates::PendingUpdates)The flush of the internal node C (see flush!). With d.uplo = 'U' (or 'L'), a diagonal block only hands its updates to the children of its upper (or lower) triangle.
HMatrices._flush_low_rank_leaf! — Method
_flush_low_rank_leaf!(C::HMatrix, updates::PendingUpdates, α, comp, buf::UpdateBuffer)Compress data(C) + Σ AₖBₖ' + α*Σ XᵢYᵢ for the admissible leaf C, with the carry (Aₖ, Bₖ) and the pending products (Xᵢ, Yᵢ).
The low-rank terms (the data, the carry, and the products with an exact low-rank form, evaluated here) are packed side by side into a single pair of factors (A, B) stored in buf.lowrank, so that the compressor samples them with one matrix-vector product, without allocating. The other products are only sampled by the compressor, through a LeafOperator.
HMatrices._frob2 — Method
_frob2(a, b)The squared Frobenius norm of the cross a bᴴ, i.e. tr(∑ᵢ aᵢᴴ aᵢ ∑ⱼ bⱼᴴ bⱼ).
HMatrices._gram — Method
_gram(x, y)∑ᵢ xᵢᴴ yᵢ. For scalar entries this is dot(x, y); for matrix entries it is a matrix, since the entries do not commute.
HMatrices._has_low_rank_form — Method
_has_low_rank_form(X, Y)Whether X*Y has an exact low-rank form computed by _compute_low_rank_term: X or Y is a low-rank leaf, or both are dense leaves. This is always the case for a product pending at an internal node with a leaf factor, since the cluster shared by X and Y is then a leaf.
HMatrices._hgemv_recursive! — Function
_hgemv_recursive!(C, A, B, offset[, buf])C[I] ← C[I] + A*B[J], where I = rowrange(A) .- offset[1] and J = colrange(A) .- offset[2]: the vectors B and C are indexed relative to offset (e.g. the offset of the block of which A is a descendant). The products with low-rank leaves use the scratch vector buf if one is given (see _leaf_gemv!).
HMatrices._hmul_tree! — Method
_hmul_tree!(C, A, B, a, b, compressor; uplo = 'N', executor = SerialExecutor())Like hmul!, in the ordering in which the H-matrices are stored, i.e. as products of the stored blocks, whatever the points they come from. With uplo = 'U' (or 'L'), only the upper (or lower) triangle of the diagonal blocks of C is updated.
HMatrices._is_low_rank — Method
_is_low_rank(X)Whether X is a low-rank (admissible) leaf.
HMatrices._last_writer! — Method
_last_writer!(ex::ThreadsExecutor, x)The piece of work after which x is up to date, if any. A read of an internal block of an HMatrix, which is final, waits for a join over the last writers of its leaves, created once.
HMatrices._ldiv! — Method
_ldiv!(L::HLowerTriangular, B, buf)B ← L⁻¹B by block forward substitution, with the products with the low-rank blocks of L in the scratch vector buf (see _leaf_gemm!).
HMatrices._ldiv! — Method
_ldiv!(U::HUpperTriangular, B, buf)B ← U⁻¹B by block backward substitution; see _ldiv! for a lower triangle.
HMatrices._leaf_gemm! — Method
_leaf_gemm!(C, R, M, a, buf)C ← C + a*R*M for a low-rank leaf R, with the intermediate product in the scratch vector buf if one is given (and the entries are numbers).
HMatrices._leaf_gemv! — Method
_leaf_gemv!(y, d, x, buf)y ← y + d*x for the data d of a leaf, with the intermediate product of a low-rank leaf in the scratch vector buf if one is given (and the entries are numbers).
HMatrices._low_rank_term_rank — Method
_low_rank_term_rank(X, Y)The rank of the factors of X*Y computed by _compute_low_rank_term.
HMatrices._lu! — Method
_lu!(d::LazyDriver, M::HMatrix)Driver of lu! for the diagonal block M: flush M, then factor it (dense LU of a leaf), or recurse on its children, pushing the Schur complement updates.
HMatrices._modified_factor! — Method
_modified_factor!(R::RkMatrix, s::Symbol)Update what is known about the factors of R after the factor s (:A or :B) was modified in place: the other factor keeps its orthogonality, and the truncation errors are no longer known.
HMatrices._mul! — Method
_mul!(out, L::LeafOperator, V, trans::Val)out = L*V (or L'*V, see _oriented), through the products of the hierarchical matrices with the block of vectors V.
HMatrices._mul_tree! — Method
_mul_tree!(y, A, x, b, threads)Perform y <-- A*x + y*b in the ordering of the trees of A.
HMatrices._operator_col! — Method
_operator_col!(col, L::LeafOperator, trans::Val, j)The column j of L (or of its adjoint, see _oriented), in col.
HMatrices._oriented — Method
_oriented(L::LeafOperator, ::Val{trans})The low-rank factors and the coefficient of L (trans = false), or of its adjoint L' = B*A' + conj(α)*∑ᵢ Yᵢ'*Xᵢ' (trans = true); see _product.
HMatrices._product — Method
_product(X, Y, ::Val{trans})The factors of the product X*Y (trans = false) or of its adjoint (trans = true).
HMatrices._randomized_svd — Method
_randomized_svd(K, comp::RandomizedSVD)The randomized SVD of K (see RandomizedSVD), through the products mul!(Y, K, X) and mul!(Y, K', X).
HMatrices._rank_of — Method
_rank_of(X)The rank of the low-rank leaf X (an HMatrix or its adjoint).
HMatrices._recompress! — Method
_recompress!(R::RkMatrix, atol, rtol, rmax)Recompress R in place by a truncated SVD (see TSVD), computed from QR factorizations of its factors, or from R itself when they would not be smaller.
HMatrices._release! — Method
_release!(ex::ThreadsExecutor, task::ExecutorTask)Decrement the number of unfinished dependencies of task, and run it once it reaches zero: a join is finished at once, the other pieces of work are spawned as tasks.
HMatrices._rkfactors — Method
_rkfactors(R)The factors (U, V) of a low-rank matrix R = U*adjoint(V).
HMatrices._rtol — Method
_rtol(rtol, atol, rank, T)The relative tolerance used to compress a matrix with entries of type T, where R is the real type underlying T. If rtol is nothing, it is sqrt(eps(R)), or the accuracy attainable with R (10eps(R)) if atol or rank is given. Throw an ArgumentError if rtol is below that accuracy.
An rtol of zero is raised to that accuracy, so that an atol too small for a block does not compress it to full rank.
HMatrices._run! — Method
_run!(driver, executor)Run driver(), which spawns work on executor, then wait for this work, also when the driver throws, so that no work outlives the call.
HMatrices._scalar_matrix — Method
_scalar_matrix(A::Matrix{<:SMatrix})The scalar matrix whose blocks are the entries of A.
HMatrices._scratch! — Method
_scratch!(buf::Vector, k)
_scratch!(buf::Vector, sz::Tuple)The first k entries of buf (as a vector), or the first prod(sz) entries (as a matrix of size sz), growing buf if needed.
HMatrices._solve_lower! — Method
_solve_lower!(d::LazyDriver, L::HLowerTriangular, X::HMatrix)X ← L⁻¹X: flush X, then solve with its data (a leaf), or recurse on its children by block forward substitution, pushing the updates X[j,k] ← X[j,k] - L[j,i]*X[i,k] (the coefficient of d is -1). L is a triangle of an HMatrix or of its adjoint (e.g. UnitLowerTriangular(D) for an LU, UpperTriangular(D)' for a Cholesky factorization), whose blocks are final.
HMatrices._solve_upper! — Method
_solve_upper!(d::LazyDriver, X::HMatrix, U::HUpperTriangular)X ← XU⁻¹; see _solve_lower!.
HMatrices._stored — Method
_stored(x)The object which an access to x reads or writes: the HMatrix underlying an adjoint, a Hermitian or a triangle of one, and x itself otherwise.
HMatrices._stored_leaf — Method
_stored_leaf(leaf)The HMatrix storing the data of a leaf of an HMatrix or of a Hermitian one: nothing for a leaf of the lower triangle of a Hermitian, which stores no data.
HMatrices._svd_truncation_error — Function
_svd_truncation_error(S, r, prior = 0.0)The truncation errors (in the Frobenius norm) of a truncated SVD with singular values S, keeping r of them, of a matrix which was itself known up to an error prior.
HMatrices._through_x — Method
_through_x(X, Y)Whether _compute_low_rank_term factors X*Y through the low-rank leaf X (rather than Y): X is a low-rank leaf, and Y is not one of smaller rank.
HMatrices._tree_matrix — Function
_tree_matrix(H, T = eltype(H))The dense Matrix{T} of H in the ordering of its cluster trees, i.e. the ordering in which H is stored.
HMatrices._truncation_rank — Method
_truncation_rank(S, atol, rtol, rmax)The number of singular values S (sorted decreasingly) to keep, at most rmax, so that the Frobenius norm of the dropped ones stays below max(atol, rtol*norm(S)).
HMatrices._update_frob_norm — Method
_update_frob_norm(acc,A,B)Given the Frobenius norm of Rₖ = A[1:end-1]*adjoint(B[1:end-1]) in acc, compute the Frobenius norm of Rₖ₊₁ = A*adjoint(B) efficiently.
HMatrices.allocate_buffer — Function
allocate_buffer(comp, T)A workspace for the compressor comp on matrices with entries of type T, which can be passed to (and reused by) its calls; nothing if comp needs none.
HMatrices.assemble_hmatrix — Function
assemble_hmatrix(K, X, Y = X; atol = 0, rtol, rank, eta = 3, nmax = 50, threads = true)Approximate the matrix K by an HMatrix, where X and Y are the points (SVectors, or elements with a center) associated with the rows and the columns of K. The points are only used to cluster the indices, and are not modified.
Kcan be anyAbstractMatrix(e.g. aKernelMatrix), with scalar orSMatrixentries;getblock!can be overloaded to compute its blocks faster. IfKis aHermitian, only its upper triangle is assembled and aHermitianHMatrixis returned (this requiresY === X).atol,rtolandrankcontrol the compression of the low-rank blocks, by a partial ACA (seePartialACA); by defaultrtol = sqrt(eps)of the real type of the entries, or only the accuracy attainable with that type ifatolorrankis given.- Two clusters are compressed if
min(diameters) < eta * distance;eta = Infcompresses every pair of disjoint clusters (weak admissibility). nmaxis the maximum number of points in a leaf of the cluster trees.- The leaves are assembled in parallel with
threads = true(when Julia runs on several threads).
Every operation on the result (products, Matrix, factorizations) uses the ordering of X and Y.
HMatrices.assemble_hmatrix — Method
assemble_hmatrix(K::AbstractKernelMatrix; kwargs...)
assemble_hmatrix(Hermitian(K::AbstractKernelMatrix); kwargs...)Approximate K by an HMatrix, clustering the elements of K by their center. The keyword arguments are those of assemble_hmatrix.
HMatrices.assemble_hmatrix — Method
assemble_hmatrix(K, rowtree::ClusterTree, coltree::ClusterTree;
adm = StrongAdmissibilityStd(), comp = PartialACA(), threads = true, executor)Lower-level version of assemble_hmatrix with given cluster trees, admissibility condition adm (called on a node of rowtree and a node of coltree to decide if the block is compressed) and compressor comp (see AbstractCompressor). The leaves are assembled by executor, a ThreadsExecutor if threads = true and Julia runs on several threads, and a SerialExecutor otherwise.
HMatrices.binary_split! — Method
binary_split!(cluster::ClusterTree,predicate)Split a ClusterTree into two, sorting all elements in the process according to predicate. cluster is assigned as parent to each children.
Each point is sorted according to whether f(x) returns true (point sorted on the "left" node) or false (point sorted on the "right" node). At the end a minimal HyperRectangle containing all left/right points is created.
HMatrices.center — Method
center(Ω)Center of the smallest ball containing Ω.
HMatrices.colelements — Method
colelements(K::AbstractKernelMatrix)The elements associated with the columns of K.
HMatrices.colperm — Method
colperm(H)Like rowperm, for the columns of H.
HMatrices.compress! — Method
compress!(R::RkMatrix, tsvd::TSVD)Recompress the matrix R using a truncated svd of R. The implementation uses the qr-svd strategy to efficiently compute svd(R) when rank(R) ≪ min(size(R)).
HMatrices.compress! — Method
compress!(M::Matrix,tsvd::TSVD)Compress the matrix M using a truncated svd and output an RkMatrix. The data in M is invalidated in the process.
HMatrices.compression_ratio — Method
compression_ratio(H::HTypes)The ratio of the uncompressed size of H to its compressed size. A compression_ratio of 10 means it would have taken 10 times more memory to store H as a dense matrix.
HMatrices.container — Method
container(clt::ClusterTree)Return the object enclosing all the elements of the clt.
HMatrices.depth — Function
depth(tree,acc=0)Recursive function to compute the depth of node in a tree-like structure.
Overload this function if your structure has a more efficient way to compute depth (e.g. if it stores it in a field).
HMatrices.diameter — Method
diameter(Ω)Largest distance between x and y for x,y ∈ Ω.
HMatrices.distance — Method
distance(X::ClusterTree, Y::ClusterTree)Distance between the containers of X and Y.
HMatrices.distance — Method
distance(Ω1,Ω2)Minimal Euclidean distance between a point x ∈ Ω1 and y ∈ Ω2.
HMatrices.elements — Method
elements(clt::ClusterTree)Iterable list of the elements inside clt.
HMatrices.factors — Method
factors(t::CarryTerm, m, n)The factors (A, B) of the restriction t = A*B', of size m × n, as views.
HMatrices.filter_tree — Function
filter_tree(f,tree,isterminal=true)Return a vector containing all the nodes of tree such that f(node)==true. The argument isterminal can be used to control whether to continue the search on children of nodes for which f(node)==true.
HMatrices.filter_tree! — Function
filter_tree!(filter,nodes,tree,[isterminal=true])Like filter_tree, but appends results to nodes.
HMatrices.flush! — Method
flush!(d::LazyDriver, C::HMatrix)Apply the updates pending at C (not those pending at its descendants):
- internal node: a pending product with a leaf factor has an exact low-rank form, which is computed once, here, and shared by the leaves below (carry); the other products are split into the products of the children; the carry is restricted to the children;
- dense leaf: the carry and the products are added exactly;
- admissible leaf: its data, its carry and the products with an exact low-rank form are written side by side as
A*B', andA*B' + α*Σ XᵢYᵢ(the other products) is compressed once (seeLeafOperator).
HMatrices.flush_tree! — Method
flush_tree!(d::LazyDriver, C::HMatrix)Flush C and all of its descendants, top-down.
HMatrices.getblock! — Method
getblock!(block,K,irange,jrange)Fill block with K[i,j] for i ∈ irange, j ∈ jrange, where block is of size length(irange) × length(jrange).
A default implementation exists which relies on getindex(K,i,j), but this method can be overloaded for better performance if e.g. a vectorized way of computing a block is available. The indices are in the ordering of K, and irange/jrange can be any vectors of integers, not only ranges.
HMatrices.getcol! — Method
getcol!(col, M, j)Return the j-th column of M in col.
HMatrices.getcol! — Method
getcol!(col, R, j)Fill col with column j of the low-rank matrix R.
HMatrices.getcol — Method
getcol(M, j)Return the j-th column of M.
HMatrices.glob2loc — Method
glob2loc(clt::ClusterTree)The inverse of loc2glob.
HMatrices.hldiv! — Method
hldiv!(L::HLowerTriangular, X::HMatrix, compressor; executor = SerialExecutor())X ← L⁻¹X for a triangle L of an HMatrix (or of its adjoint), compressing every admissible leaf of X once with compressor (see LazyDriver), the numeric work being run by executor.
HMatrices.hmul! — Method
hmul!(C::HMatrix, A, B, a, b, compressor; executor = SerialExecutor())Similar to mul! : compute C <-- A*B*a + C*b, where A,B,C are hierarchical matrices (A and B possibly adjoints, C possibly a Hermitian, of which only the stored triangle is updated). Every admissible leaf of C is compressed once, with compressor, from its data and all the products which reach it (see LazyDriver), the numeric work being run by executor.
The rows of A and C, the columns of A and the rows of B, and the columns of B and C must be clustered in the same way (e.g. built from the same points); otherwise an ArgumentError is thrown.
HMatrices.hrdiv! — Method
hrdiv!(X::HMatrix, U::HUpperTriangular, compressor; executor = SerialExecutor())X ← XU⁻¹ for a triangle U of an HMatrix (or of its adjoint); see hldiv!.
HMatrices.index_range — Method
index_range(clt::ClusterTree)Indices of elements in root_elements(clt) which lie inside clt.
HMatrices.isclean — Method
isclean(H::HMatrix)Return true if all leaves of H have data, and if the leaves are the only nodes containing data. This is the normal state of an ℋ-matrix, but during intermediate stages of a computation data may be associated with non-leaf nodes for convenience.
HMatrices.leaves — Method
leaves(tree)Return a vector containing all the leaf nodes of tree.
HMatrices.loc2glob — Method
loc2glob(clt::ClusterTree)The permutation from the (local) indexing system of the elements of the clt to the (global) indexes used upon the construction of the tree.
HMatrices.newcol! — Method
newcol!(A::VectorOfVectors)Append a new (uninitialized) column to A, and return a view of it.
HMatrices.nodes — Method
nodes(tree)Return a vector containing all the nodes of tree.
HMatrices.parentnode — Method
parentnode(clt::ClusterTree)The node's parent. If t is a root, then parent(t)==t.
HMatrices.pending! — Method
pending!(d::LazyDriver, C::HMatrix)The PendingUpdates of C, created if C has none.
HMatrices.radius — Method
radius(Ω)Half the diameter.
HMatrices.reset! — Method
reset!(A::VectorOfVectors)Set the number of columns of A to zero, and the number of rows to zero, but does not resize! the underlying data vector.
HMatrices.root_elements — Method
root_elements(clt::ClusterTree)The elements contained in the root of the tree to which clt belongs.
HMatrices.rowelements — Method
rowelements(K::AbstractKernelMatrix)The elements associated with the rows of K.
HMatrices.rowperm — Method
rowperm(H)The permutation of the rows of the whole matrix into the ordering in which it is stored: for the root H of an HMatrix, the stored row i is the row rowperm(H)[i] of the matrix approximated by H. For a block of H, it is the permutation of the whole matrix (the rows of the block are rowperm(H)[rowrange(H)]).
The returned vector belongs to the cluster tree and must not be modified.
HMatrices.should_split — Function
should_split(clt::ClusterTree, depth, splitter::AbstractSplitter)Determine whether or not a ClusterTree should be further divided.
HMatrices.split! — Function
split!(clt::ClusterTree,splitter::AbstractSplitter)Divide clt using the strategy implemented by splitter. This function is responsible for assigning the children and parentnode fields, as well as of permuting the data of clt.
HMatrices.with_buffer — Method
with_buffer(f, d::LazyDriver)f(buf) with a workspace buf (an UpdateBuffer) used by no other piece of work at the same time (see with_workspace).
HMatrices.with_workspace — Method
with_workspace(f, pool, make)f(w) with a workspace w used by no other piece of work at the same time: taken from pool (see workspaces), or made by make() if the pool is empty, then put back in pool. A piece of work never waits for a workspace, and the pool grows to the number of pieces of work running at the same time.
HMatrices.workspaces — Method
workspaces(T)An empty pool of workspaces of type T, for with_workspace.
LinearAlgebra.cholesky! — Method
cholesky!(M::HermitianHMatrix, compressor; threads = true, executor)Hierarchical Cholesky factorization M = U'U in place, the factor being stored in the upper triangle of M, which must hold the data of M (as for the Hermitian assembled by assemble_hmatrix); an ArgumentError is thrown otherwise. As for lu!, every update is deferred, each admissible leaf of the factor is compressed once, and the work is parallelized with threads = true or run by the given executor.
F \ b solves in the ordering of the points used to assemble M. The factors F.L and F.U are stored in the ordering of the cluster tree, with F.L * (F.U * x) ≈ Matrix(M)[F.p, F.p] * x; products and solves with them act in that ordering.
LinearAlgebra.cholesky! — Method
cholesky!(M::HermitianHMatrix; atol, rank, rtol, block, threads = true)Hierarchical Cholesky factorization of M, using the RandomizedSVD(; atol, rank, rtol, block) compressor (see RandomizedSVD).
LinearAlgebra.cholesky — Method
cholesky(M::HermitianHMatrix, args...; kwargs...)Hierarchical Cholesky factorization. See cholesky! for the available options.
LinearAlgebra.lu! — Method
lu!(M::HMatrix, compressor; threads = true, executor)Hierarchical LU factorization of M in place, every update being deferred: each admissible leaf of the factors is compressed exactly once, with compressor (e.g. RandomizedSVD or PartialACA), from its Schur complement. The work is parallelized with threads = true (when Julia runs on several threads), or run by the given executor (ThreadsExecutor or SerialExecutor).
F \ b solves in the ordering of the points used to assemble M. The factors F.L and F.U are stored in the ordering of the cluster trees, with F.L * (F.U * x) ≈ Matrix(M)[F.p, F.q] * x; products and solves with them act in that ordering.
The entries of M must be numbers. With threads = true, BLAS should run on a single thread (BLAS.set_num_threads(1)), since the parallelism comes from the blocks. An error raised by a threaded factorization is rethrown without the backtrace of the task which raised it; threads = false gives the full backtrace.
LinearAlgebra.lu! — Method
lu!(M::HMatrix; atol, rank, rtol, block, threads = true)Hierarchical LU factorization of M, using the RandomizedSVD(; atol, rank, rtol, block) compressor (see RandomizedSVD).
LinearAlgebra.lu — Method
LinearAlgebra.lu(M::HMatrix,args...;kwargs...)Hierarchical LU factorization. See lu! for the available options.
LinearAlgebra.mul! — Function
mul!(y::AbstractVector,H::HMatrix,x::AbstractVector,a,b[;threads])Perform y <-- H*x*a + y*b in place.
LinearAlgebra.rdiv! — Function
rdiv!(R::RkMatrix, U::HUpperTriangular[, buf::Vector])R ← R*U⁻¹, forming the transposed factor in the scratch vector buf (grown if needed).