Developer Interface

MatrixAlgebraKit.jl provides a developer interface for specifying custom algorithm backends and selecting default algorithms.

MatrixAlgebraKit.default_algorithmFunction
MatrixAlgebraKit.default_algorithm(f, A; kwargs...)
MatrixAlgebraKit.default_algorithm(f, ::Type{TA}; kwargs...) where {TA}

Select the default algorithm for a given factorization function f and input A. In general, this is called by select_algorithm if no algorithm is specified explicitly. New types should prefer to register their default algorithms in the type domain.

source
MatrixAlgebraKit.select_algorithmFunction
MatrixAlgebraKit.select_algorithm(f, A, alg::AbstractAlgorithm)
MatrixAlgebraKit.select_algorithm(f, A, alg::Symbol; kwargs...)
MatrixAlgebraKit.select_algorithm(f, A, alg::Type; kwargs...)
MatrixAlgebraKit.select_algorithm(f, A; kwargs...)
MatrixAlgebraKit.select_algorithm(f, A, (; kwargs...))

Decide on an algorithm to use for implementing the function f on inputs of type A. This can be obtained both for values A or types A.

If alg is an AbstractAlgorithm instance, it will be returned as-is.

If alg is a Symbol or a Type of algorithm, the return value is obtained by calling the corresponding algorithm constructor; keyword arguments in kwargs are passed along to this constructor.

If alg is not specified (or nothing), an algorithm will be selected automatically with MatrixAlgebraKit.default_algorithm and the keyword arguments in kwargs will be passed to the algorithm constructor. Finally, the same behavior is obtained when the keyword arguments are passed as the third positional argument in the form of a NamedTuple.

source
MatrixAlgebraKit.findtruncatedFunction
MatrixAlgebraKit.findtruncated(values::AbstractVector, strategy::TruncationStrategy)

Generic interface for finding truncated values of the spectrum of a decomposition based on the strategy. The output should be a collection of indices specifying which values to keep. MatrixAlgebraKit.findtruncated is used inside of the default implementation of truncate! to perform the truncation. It does not assume that the values are sorted. For a version that assumes the values are reverse sorted (which is the standard case for SVD) see MatrixAlgebraKit.findtruncated_sorted.

source
MatrixAlgebraKit.findtruncated_sortedFunction
MatrixAlgebraKit.findtruncated_sorted(values::AbstractVector, strategy::TruncationStrategy)

Like MatrixAlgebraKit.findtruncated but assumes that the values are sorted in reverse order. They are assumed to be sorted in a way that is consistent with the truncation strategy, which generally means they are sorted by absolute value but some truncation strategies allow customizing that. However, note that this assumption is not checked, so passing values that are not sorted in the correct way can silently give unexpected results. This is used in the default implementation of svd_trunc!.

source