pub fn qr_with<T>(
t: &TensorDynLen,
left_inds: &[DynIndex],
options: &QrOptions,
) -> Result<(TensorDynLen, TensorDynLen), QrError>Expand description
Compute QR decomposition of a tensor with arbitrary rank, returning (Q, R).
This function allows per-call control of the truncation tolerance via QrOptions.
If options.rtol is None, uses the global default rtol.
This function computes the thin QR decomposition, where for an unfolded matrix A (m×n), we return Q (m×k) and R (k×n) with k = min(m, n).
The input tensor can have any rank >= 2, and indices are split into left and right groups. The tensor is unfolded into a matrix by grouping left indices as rows and right indices as columns.
Truncation is performed based on R’s row norms: rows whose norm is below
rtol * max_row_norm are discarded.
For the mathematical convention: [ A = Q * R ] where Q is orthogonal (or unitary for complex) and R is upper triangular.
§Arguments
t- Input tensor with DenseF64 or DenseC64 storageleft_inds- Indices to place on the left (row) side of the unfolded matrixoptions- QR options including rtol for truncation control
§Returns
A tuple (Q, R) where:
Qis a tensor with indices[left_inds..., bond_index]and dimensions[left_dims..., r]Ris a tensor with indices[bond_index, right_inds...]and dimensions[r, right_dims...]whereris the retained rank (≤ min(m, n)) determined by rtol truncation.
§Errors
Returns QrError if:
- The tensor rank is < 2
- Storage is not DenseF64 or DenseC64
left_indsis empty or contains all indicesleft_indscontains indices not in the tensor or duplicates- The QR computation fails
options.rtolis invalid (not finite or negative)