TensorPlay
API reference
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-08

tensorplay.linalg API

Functions 44

#

diagonal

functionFull reference ↗
tensorplay.linalg.diagonal()

linalg_diagonal(A, *, offset=0, dim1=-2, dim2=-1) -> Tensor

Returns a view of the diagonals of A: the two dimensions selected by dim1 and dim2 are collapsed into the trailing axis of the output, holding the entries of the diagonal shifted by offset (positive shifts above, negative below the main diagonal).

See tensorplay.diagonal()

#

householder_product

functionFull reference ↗
tensorplay.linalg.householder_product()

linalg_householder_product(Tensor input, Tensor tau) -> Tensor linalg_householder_product.out(Tensor input, Tensor tau, *, Tensor(a!) out) -> Tensor(a!)

#

ldl_factor_ex

functionFull reference ↗
tensorplay.linalg.ldl_factor_ex()

linalg_ldl_factor_ex(Tensor A, *, bool hermitian=False, bool check_errors=False) -> (Tensor LD, Tensor pivots, Tensor info) linalg_ldl_factor_ex.out(Tensor self, *, bool hermitian=False, bool check_errors=False, Tensor(a!) LD, Tensor(b!) pivots, Tensor(c!) info) -> (Tensor(a!) LD, Tensor(b!) pivots, Tensor(c!) info)

#

ldl_factor

functionFull reference ↗
tensorplay.linalg.ldl_factor()

linalg_ldl_factor(Tensor A, *, bool hermitian=False) -> (Tensor LD, Tensor pivots) linalg_ldl_factor.out(Tensor self, *, bool hermitian=False, Tensor(a!) LD, Tensor(b!) pivots) -> (Tensor(a!) LD, Tensor(b!) pivots)

#

ldl_solve

functionFull reference ↗
tensorplay.linalg.ldl_solve()

linalg_ldl_solve(Tensor LD, Tensor pivots, Tensor B, *, bool hermitian=False) -> Tensor linalg_ldl_solve.out(Tensor LD, Tensor pivots, Tensor B, *, bool hermitian=False, Tensor(a!) out) -> Tensor(a!)

#

lu_factor_ex

functionFull reference ↗
tensorplay.linalg.lu_factor_ex()

linalg_lu_factor_ex(Tensor A, *, bool pivot=True, bool check_errors=False) -> (Tensor LU, Tensor pivots, Tensor info) linalg_lu_factor_ex.out(Tensor A, *, bool pivot=True, bool check_errors=False, Tensor(a!) LU, Tensor(b!) pivots, Tensor(c!) info) -> (Tensor(a!) LU, Tensor(b!) pivots, Tensor(c!) info)

#

lu_factor

functionFull reference ↗
tensorplay.linalg.lu_factor()

linalg_lu_factor(Tensor A, *, bool pivot=True) -> (Tensor LU, Tensor pivots) linalg_lu_factor.out(Tensor A, *, bool pivot=True, Tensor(a!) LU, Tensor(b!) pivots) -> (Tensor(a!) LU, Tensor(b!) pivots)

#

lu_solve

functionFull reference ↗
tensorplay.linalg.lu_solve()

linalg_lu_solve(Tensor LU, Tensor pivots, Tensor B, *, bool left=True, bool adjoint=False) -> Tensor linalg_lu_solve.out(Tensor LU, Tensor pivots, Tensor B, *, bool left=True, bool adjoint=False, Tensor(a!) out) -> Tensor(a!)

#

lu

functionFull reference ↗
tensorplay.linalg.lu()

linalg_lu(Tensor A, *, bool pivot=True) -> (Tensor P, Tensor L, Tensor U) linalg_lu.out(Tensor A, *, bool pivot=True, Tensor(a!) P, Tensor(b!) L, Tensor(c!) U) -> (Tensor(a!) P, Tensor(b!) L, Tensor(c!) U)

#

matrix_exp

functionFull reference ↗
tensorplay.linalg.matrix_exp(A) → Tensor[source]

Square matrix exponential via the degree-13 Pade approximant with scaling and squaring: A is halved until its 1-norm falls under the approximant’s accuracy threshold, then the result is squared back.

#

matrix_rank

functionFull reference ↗
tensorplay.linalg.matrix_rank(A, *, atol=None, rtol=None, hermitian=False)[source]

Computes the numerical rank of each matrix in A.

A singular value counts towards the rank when it exceeds the sum of an absolute tolerance and a relative tolerance scaled by the largest singular value of its matrix.

Parameters:
  • A (Tensor) – tensor of shape (..., m, n) holding the matrices.

  • atol (float, Tensor, optional) – absolute threshold applied to the singular values. Defaults to 0.

  • rtol (float, Tensor, optional) – relative threshold applied to the largest singular value. Defaults to max(m, n) times the machine epsilon of A’s dtype.

  • hermitian (bool) – when True, A is treated as Hermitian and its rank is derived from eigenvalues instead of singular values.

Returns:

integer tensor with the rank of each matrix, with the batch dimensions of A.

Return type:

Tensor

#

matrix_sqrth

functionFull reference ↗
tensorplay.linalg.matrix_sqrth(A) → Tensor[source]

Matrix square root via the Denman-Beavers fixed-point iteration (converges for matrices with no eigenvalues on the closed negative real axis).

#

multi_dot

functionFull reference ↗
tensorplay.linalg.multi_dot(tensors) → Tensor[source]

Chained matrix product evaluated in the parenthesization that minimizes the scalar multiplication count (matrix-chain dynamic program).

#

pinv

functionFull reference ↗
tensorplay.linalg.pinv(A, *, atol=None, rtol=None, hermitian=False) → Tensor[source]

Moore-Penrose pseudo-inverse. Singular values (eigenvalue magnitudes when hermitian) at or below max(atol, rtol * sigma_max) are treated as zero; rtol defaults to eps * max(m, n), or to zero when only a positive atol is given. The tolerances may be floats or tensors that broadcast against the batch.

#

solve_triangular

functionFull reference ↗
tensorplay.linalg.solve_triangular()

linalg_solve_triangular(Tensor A, Tensor B, *, bool upper, bool left=True, bool unitriangular=False) -> Tensor linalg_solve_triangular.out(Tensor self, Tensor B, *, bool upper, bool left=True, bool unitriangular=False, Tensor(a!) out) -> Tensor(a!)

#

tensorinv

functionFull reference ↗
tensorplay.linalg.tensorinv(A, ind=2) → Tensor[source]

Inverse of A seen as a square matrix over the split at ind: the product of the leading ind dimensions must equal that of the rest.

#

tensorsolve

functionFull reference ↗
tensorplay.linalg.tensorsolve(A, B, dims=None) → Tensor[source]

Solves the tensor equation A X = B after flattening the contracted dimensions into a square matrix. dims identifies dimensions of A that should be moved to the trailing side before the flattening step.

#

vecdot

functionFull reference ↗
tensorplay.linalg.vecdot(x, y, *, dim=-1) → Tensor[source]

Dot product along dim with the first argument conjugated for complex inputs.

#

vector_norm

functionFull reference ↗
tensorplay.linalg.vector_norm(x, ord=2, dim=None, keepdim=False) → Tensor[source]

dim=None norms the whole tensor: the input is flattened first, and keepdim then restores the reduced axes as ones.

Classes 7

#

CholeskyExResult

classFull reference ↗
class tensorplay.linalg.CholeskyExResult(L, info)
L

Alias for field number 0

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

info

Alias for field number 1

#

EighResult

classFull reference ↗
class tensorplay.linalg.EighResult(eigenvalues, eigenvectors)
count(value, /)

Return number of occurrences of value.

eigenvalues

Alias for field number 0

eigenvectors

Alias for field number 1

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

#

EigResult

classFull reference ↗
class tensorplay.linalg.EigResult(eigenvalues, eigenvectors)
count(value, /)

Return number of occurrences of value.

eigenvalues

Alias for field number 0

eigenvectors

Alias for field number 1

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

#

LstsqResult

classFull reference ↗
class tensorplay.linalg.LstsqResult(solution, residuals, rank, singular_values)
count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

rank

Alias for field number 2

residuals

Alias for field number 1

singular_values

Alias for field number 3

solution

Alias for field number 0

#

QRResult

classFull reference ↗
class tensorplay.linalg.QRResult(Q, R)
Q

Alias for field number 0

R

Alias for field number 1

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

#

SlogdetResult

classFull reference ↗
class tensorplay.linalg.SlogdetResult(sign, logabsdet)
count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

logabsdet

Alias for field number 1

sign

Alias for field number 0

#

SVDResult

classFull reference ↗
class tensorplay.linalg.SVDResult(U, S, Vh)
S

Alias for field number 1

U

Alias for field number 0

Vh

Alias for field number 2

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

Exceptions 1

#

LinAlgError

exceptionFull reference ↗
exception tensorplay.linalg.LinAlgError[source]

Raised when a decomposition or solve fails on a numerically invalid input.

On this page

Ask DeepWiki