linalg#
Linear algebra routines with broadcasting and complex value support.
This module exists because support for broadcasting and complex values is spotty in the NumPy and CuPy libraries.
- tike.linalg.inner(x, y, axis=None, keepdims=False)[source]#
Return the complex inner product; the order of the operands matters.
- tike.linalg.lstsq(a, b, weights=None)[source]#
Return the least-squares solution for a @ x = b.
This implementation, unlike cp.linalg.lstsq, allows a stack of matricies to be processed simultaneously. The input sizes of the matricies are as follows:
a (…, M, N) b (…, M, K) x (…, N, K)
Optionally include weights (…, M) for weighted-least-squares if the errors are uncorrelated.
- …seealso:: numpy/numpy#8720
- tike.linalg.mnorm(x, axis=None, keepdims=False)[source]#
Return the vector 2-norm of x but replace sum with mean.
- tike.linalg.norm(x, axis=None, keepdims=False)[source]#
Return the vector 2-norm of x along given axis.
- tike.linalg.orthogonalize_gs(x, axis=-1, N=None)[source]#
Gram-schmidt orthogonalization for complex arrays.
- Parameters
x ((..., D) array) – containing dimensions to be orthogonalized.
axis (Union[int, Tuple[int, ...]]) – The axis/axes to be orthogonalized. By default only the last axis is orthogonalized. If axis is a tuple, then the number of orthogonal vectors is the length of the last dimension not included in axis. The other dimensions are broadcast.
N (Optional[int]) – The axis along which to orthogonalize. Other dimensions are broadcast.
- tike.linalg.pca_eig(data, k)[source]#
Return k principal components via Eigen decomposition.
- Parameters
data ((..., N, D) array) – N observations of a D dimensional space.
k (int) – The number of principle components.
- Returns
S ((…, k) array) – The singular values corresponding to the current principal components sorted largest to smallest.
U ((…, D, k) array) – The current best principal components of the population.
- Return type
Tuple[numpy.typing.NDArray, numpy.typing.NDArray]