Reference
TensorAlgebra.LinearBroadcasted — Type
LinearBroadcastedAbstract supertype for lazy linear broadcast expressions. Analogous to Base.Broadcast.Broadcasted but restricted to linear operations.
Materializes via the protocol: copy(lb) = copyto!(similar(lb), lb) copyto!(dest, lb) → add!(dest, lb, 1, 0)
TensorAlgebra.add! — Method
add!(dest, src, α, β)dest = β * dest + α * src.
TensorAlgebra.add! — Method
add!(dest, src)dest .+= src.
TensorAlgebra.eigen — Function
eigen(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> D, V
eigen(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> D, V
eigen(A::AbstractArray, ndims_codomain::Val; kwargs...) -> D, V
eigen(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> D, VCompute the eigenvalue decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
ishermitian::Bool: specify if the matrix is Hermitian, which can be used to speed up the computation. Iffalse, the outputeltypewill always be<:Complex.trunc: Truncation keywords foreig(h)_trunc.- Other keywords are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.eig_full!, MatrixAlgebraKit.eig_trunc!, MatrixAlgebraKit.eig_vals!, MatrixAlgebraKit.eigh_full!, MatrixAlgebraKit.eigh_trunc!, and MatrixAlgebraKit.eigh_vals!.
TensorAlgebra.eigvals — Function
eigvals(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> D
eigvals(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> D
eigvals(A::AbstractArray, ndims_codomain::Val; kwargs...) -> D
eigvals(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> DCompute the eigenvalues of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation. The output is a vector of eigenvalues.
Keyword arguments
ishermitian::Bool: specify if the matrix is Hermitian, which can be used to speed up the computation. Iffalse, the outputeltypewill always be<:Complex.- Other keywords are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.eig_vals! and MatrixAlgebraKit.eigh_vals!.
TensorAlgebra.factorize — Function
factorize(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> X, Y
factorize(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> X, Y
factorize(A::AbstractArray, ndims_codomain::Val; kwargs...) -> X, Y
factorize(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> X, YCompute the decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
orth::Symbol=:left: specify the orthogonality of the decomposition. Currently only:leftand:rightare supported.- Other keywords are passed on directly to MatrixAlgebraKit.
TensorAlgebra.islinearbroadcast — Method
islinearbroadcast(f, args...) -> BoolPer-node trait: can (f, args...) be expressed as a LinearBroadcasted? Extensible by downstream packages for additional linear operations.
TensorAlgebra.left_null — Function
left_null(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> N
left_null(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> N
left_null(A::AbstractArray, ndims_codomain::Val; kwargs...) -> N
left_null(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> NCompute the left nullspace of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation. The output satisfies N' * A ≈ 0 and N' * N ≈ I.
Keyword arguments
atol::Real=0: absolute tolerance for the nullspace computation.rtol::Real=0: relative tolerance for the nullspace computation.kind::Symbol: specify the kind of decomposition used to compute the nullspace. The options are:qr,:qrposand:svd. The former two require0 == atol == rtol. The default is:qrposifatol == rtol == 0, and:svdotherwise.
TensorAlgebra.left_orth — Function
left_orth(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> V, C
left_orth(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> V, C
left_orth(A::AbstractArray, ndims_codomain::Val; kwargs...) -> V, C
left_orth(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> V, CCompute the left orthogonal decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
- Keyword arguments are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.left_orth!.
TensorAlgebra.left_polar — Function
left_polar(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> W, P
left_polar(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> W, P
left_polar(A::AbstractArray, ndims_codomain::Val; kwargs...) -> W, P
left_polar(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> W, PCompute the left polar decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
- Keyword arguments are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.left_polar!.
TensorAlgebra.linearbroadcasted — Function
linearbroadcasted(f, args...)Construct a LinearBroadcasted subtype from function f and arguments. Analogous to Base.Broadcast.broadcasted(f, args...).
Examples
linearbroadcasted(*, 2.0, a) # ScaledBroadcasted(2.0, a)
linearbroadcasted(conj, a) # ConjBroadcasted(a)
linearbroadcasted(+, a, b) # AddBroadcasted(a, b)TensorAlgebra.lq — Function
lq(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> L, Q
lq(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> L, Q
lq(A::AbstractArray, ndims_codomain::Val; kwargs...) -> L, Q
lq(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> L, QCompute the LQ decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
full::Bool=false: select between a "full" or a "compact" decomposition, whereQis unitary orLis square, respectively.positive::Bool=false: specify if the diagonal ofLshould be positive, leading to a unique decomposition.- Other keywords are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.lq_full! and MatrixAlgebraKit.lq_compact!.
TensorAlgebra.permutedimsadd! — Method
permutedimsadd!(dest, src, perm, α, β)dest = β * dest + α * permutedims(src, perm).
TensorAlgebra.permutedimsopadd! — Method
permutedimsopadd!(dest, op, src, perm, α, β)dest = β * dest + α * permutedims(op.(src), perm).
This is the single materialization primitive for LinearBroadcasted types. Downstream array types should implement this function. The op is an element-wise linear map (e.g., identity, conj, adjoint, transpose, Float32).
The default implementation applies op element-wise, permutes, then accumulates via broadcasting with Strided.jl optimization when possible.
TensorAlgebra.qr — Function
qr(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> Q, R
qr(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> Q, R
qr(A::AbstractArray, ndims_codomain::Val; kwargs...) -> Q, R
qr(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> Q, RCompute the QR decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
full::Bool=false: select between a "full" or a "compact" decomposition, whereQis unitary orRis square, respectively.positive::Bool=false: specify if the diagonal ofRshould be positive, leading to a unique decomposition.- Other keywords are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.qr_full! and MatrixAlgebraKit.qr_compact!.
TensorAlgebra.right_null — Function
right_null(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> Nᴴ
right_null(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> Nᴴ
right_null(A::AbstractArray, ndims_codomain::Val::Val; kwargs...) -> Nᴴ
right_null(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> NᴴCompute the right nullspace of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation. The output satisfies A * Nᴴ' ≈ 0 and Nᴴ * Nᴴ' ≈ I.
Keyword arguments
atol::Real=0: absolute tolerance for the nullspace computation.rtol::Real=0: relative tolerance for the nullspace computation.kind::Symbol: specify the kind of decomposition used to compute the nullspace. The options are:lq,:lqposand:svd. The former two require0 == atol == rtol. The default is:lqposifatol == rtol == 0, and:svdotherwise.
TensorAlgebra.right_orth — Function
right_orth(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> C, V
right_orth(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> C, V
right_orth(A::AbstractArray, ndims_codomain::Val; kwargs...) -> C, V
right_orth(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> C, VCompute the right orthogonal decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
- Keyword arguments are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.right_orth!.
TensorAlgebra.right_polar — Function
right_polar(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> P, W
right_polar(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> P, W
right_polar(A::AbstractArray, ndims_codomain::Val; kwargs...) -> P, W
right_polar(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> P, WCompute the right polar decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
- Keyword arguments are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.right_polar!.
TensorAlgebra.svd — Function
svd(A::AbstractArray, labels_A, labels_codomain, labels_domain; kwargs...) -> U, S, Vᴴ
svd(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}; kwargs...) -> U, S, Vᴴ
svd(A::AbstractArray, ndims_codomain::Val; kwargs...) -> U, S, Vᴴ
svd(A::AbstractArray, biperm::AbstractBlockPermutation{2}; kwargs...) -> U, S, VᴴCompute the SVD decomposition of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation.
Keyword arguments
full::Bool=false: select between a "thick" or a "thin" decomposition, where bothUandVᴴare unitary or isometric.trunc: Truncation keywords forsvd_trunc. Not compatible withfull=true.- Other keywords are passed on directly to MatrixAlgebraKit.
See also MatrixAlgebraKit.svd_full!, MatrixAlgebraKit.svd_compact!, and MatrixAlgebraKit.svd_trunc!.
TensorAlgebra.svdvals — Function
svdvals(A::AbstractArray, labels_A, labels_codomain, labels_domain) -> S
svdvals(A::AbstractArray, perm_codomain::Tuple{Vararg{Int}}, perm_domain::Tuple{Vararg{Int}}) -> S
svdvals(A::AbstractArray, ndims_codomain::Val) -> S
svdvals(A::AbstractArray, biperm::AbstractBlockPermutation{2}) -> SCompute the singular values of a generic N-dimensional array, by interpreting it as a linear map from the domain to the codomain indices. These can be specified either via their labels or directly through a bi-permutation. The output is a vector of singular values.
See also MatrixAlgebraKit.svd_vals!.
TensorAlgebra.tryflattenlinear — Method
tryflattenlinear(bc::Broadcasted) -> LinearBroadcasted or nothingRecursively convert a Broadcasted tree to a LinearBroadcasted tree. Returns nothing if any node is not linear (as determined by islinearbroadcast).
Analogous to Broadcast.flatten for Broadcasted trees, but converts to LinearBroadcasted subtypes via linearbroadcasted.
Downstream styles call this from Base.copy(::Broadcasted{MyStyle}) to opt into linear broadcasting at materialization time.
TensorAlgebra.MatrixAlgebra.truncdegen — Method
truncdegen(trunc::TruncationStrategy; atol::Real=0, rtol::Real=0)Modify a truncation strategy so that if the truncation falls within a degenerate subspace, the entire subspace gets truncated as well. A value val is considered degenerate if norm(val - truncval) ≤ max(atol, rtol * norm(truncval)) where truncval is the largest value truncated by the original truncation strategy trunc.
For now, this truncation strategy assumes the spectrum being truncated has already been reverse sorted and the strategy being wrapped outputs a contiguous subset of values including the largest one. It also only truncates for now, so may not respect if a minimum dimension was requested in the strategy being wrapped. These restrictions may be lifted in the future or provided through a different truncation strategy.