Backends

TensorRSVD supports three array backends: NumPy (default), JAX, and CuPy. The backend is selected by passing the backend keyword argument to any top-level or core function.

If your tensor is defined through JAX, the callable (the tensor function) must be JAX-traceable. This means it must be compatible with JAX’s JIT compilation (i.e., it must be a pure function without side effects) and it must use JAX’s array operations only.

All linear-algebra primitives (QR, SVD, random normal sampling) and array creation routines are resolved at runtime through the helper functions below, which return the correct callable for the requested backend.

Linear algebra

tensorrsvd.backends.get_qr(backend)[source]

Return the QR decomposition function for the given backend.

Parameters:

backend (str)

Return type:

Callable

tensorrsvd.backends.get_svd(backend)[source]

Return a full_matrices=False SVD function for the given backend.

Parameters:

backend (str)

Return type:

Callable

Random sampling

tensorrsvd.backends.get_normal(backend, seed=0)[source]

Return a standard-normal sampling function for the given backend.

Parameters:
Return type:

Callable

Array creation

tensorrsvd.backends.get_arange(backend)[source]

Return the arange function for the given backend.

Parameters:

backend (str)

Return type:

Callable

tensorrsvd.backends.get_meshgrid(backend)[source]

Return the meshgrid function for the given backend.

Parameters:

backend (str)

Return type:

Callable

tensorrsvd.backends.get_empty(backend)[source]

Return the empty-array constructor for the given backend.

Parameters:

backend (str)

Return type:

Callable

tensorrsvd.backends.get_zeros(backend)[source]

Return the zeros-array constructor for the given backend.

Parameters:

backend (str)

Return type:

Callable

Element-wise operations

tensorrsvd.backends.get_conj(backend)[source]

Return the complex-conjugate function for the given backend.

Parameters:

backend (str)

Return type:

Callable

tensorrsvd.backends.get_ravel(backend)[source]

Return the ravel function for the given backend.

Parameters:

backend (str)

Return type:

Callable

Dtype utilities

tensorrsvd.backends.is_complex(dtype_like)[source]

Return True if dtype_like is a complex dtype.

Parameters:

dtype_like (DTypeLike)

Return type:

bool

tensorrsvd.backends.real_dtype(dtype_like)[source]

Return the real counterpart of dtype_like (unchanged if already real).

Parameters:

dtype_like (DTypeLike)

Return type:

dtype