Minimal linear algebra helpers for Arr (transpose, matmul, Cholesky, inverse, etc.).
More...
#include <ellalgo/arr.hpp>
#include <random>
Go to the source code of this file.
|
| Arr | transpose (const Arr &a) |
| | Transpose a 2D matrix.
|
| |
| Arr | flatten (const Arr &a) |
| | Flatten a matrix or vector into a 1D array.
|
| |
| Arr | diagonal (const Arr &a) |
| | Extract the diagonal of a square matrix.
|
| |
| double | trace (const Arr &a) |
| | Compute the trace of a square matrix (sum of diagonal elements).
|
| |
| double | norm (const Arr &a) |
| | Compute the Frobenius norm of an array.
|
| |
| Arr | matmul (const Arr &A, const Arr &B) |
| | Multiply two matrices: A * B.
|
| |
| Arr | cholesky (const Arr &A) |
| | Cholesky decomposition: A = L * L^T for SPD matrices.
|
| |
| Arr | inv (const Arr &A) |
| | Compute the inverse of a symmetric positive definite matrix via Cholesky.
|
| |
| std::mt19937_64 & | global_rng () |
| | Get the global Mersenne Twister random number generator.
|
| |
| void | random_seed (unsigned seed) |
| | Seed the global random number generator.
|
| |
| Arr | randn (size_t n) |
| | Generate a vector of standard normal random numbers.
|
| |
| std::pair< Arr, Arr > | meshgrid (const Arr &x, const Arr &y) |
| | Create 2D meshgrid arrays from 1D coordinate vectors.
|
| |
| Arr | stack (const Arr &a, const Arr &b, int=0) |
| | Stack two 1D arrays as rows into a 2D matrix.
|
| |
Minimal linear algebra helpers for Arr (transpose, matmul, Cholesky, inverse, etc.).
◆ cholesky()
| Arr cholesky |
( |
const Arr & |
A | ) |
|
|
inline |
Cholesky decomposition: A = L * L^T for SPD matrices.
\[
A = LL^T, \quad L_{jj} = \sqrt{A_{jj} - \sum_{k=1}^{j-1} L_{jk}^2},
\quad L_{ij} = \frac{1}{L_{jj}}\Bigl(A_{ij} - \sum_{k=1}^{j-1} L_{ik} L_{jk}\Bigr)
\]
- Parameters
-
| A | Symmetric positive definite matrix |
- Returns
- Lower-triangular Cholesky factor L
◆ diagonal()
| Arr diagonal |
( |
const Arr & |
a | ) |
|
|
inline |
Extract the diagonal of a square matrix.
- Parameters
-
- Returns
- 1D array containing diagonal elements
◆ flatten()
| Arr flatten |
( |
const Arr & |
a | ) |
|
|
inline |
Flatten a matrix or vector into a 1D array.
- Parameters
-
- Returns
- Flattened 1D array
◆ global_rng()
| std::mt19937_64 & global_rng |
( |
| ) |
|
|
inline |
Get the global Mersenne Twister random number generator.
- Returns
- Reference to the global RNG
◆ inv()
Compute the inverse of a symmetric positive definite matrix via Cholesky.
Computes \(A^{-1}\) by solving \(LY = I\) (forward substitution) then \(L^T X = Y\) (back substitution).
- Parameters
-
- Returns
- Inverse matrix
◆ matmul()
| Arr matmul |
( |
const Arr & |
A, |
|
|
const Arr & |
B |
|
) |
| |
|
inline |
Multiply two matrices: A * B.
\[
(AB)_{ij} = \sum_{k=1}^{p} A_{ik} B_{kj}
\]
- Parameters
-
| A | Left matrix (m x k) |
| B | Right matrix (k x n) |
- Returns
- Result matrix (m x n)
◆ meshgrid()
| std::pair< Arr, Arr > meshgrid |
( |
const Arr & |
x, |
|
|
const Arr & |
y |
|
) |
| |
|
inline |
Create 2D meshgrid arrays from 1D coordinate vectors.
- Parameters
-
| x | 1D x-coordinates |
| y | 1D y-coordinates |
- Returns
- Pair of 2D arrays (XX, YY)
◆ norm()
| double norm |
( |
const Arr & |
a | ) |
|
|
inline |
Compute the Frobenius norm of an array.
\( \|A\|_F = \sqrt{\sum_{i}\sum_{j} A_{ij}^2} \)
- Parameters
-
- Returns
- Frobenius norm
◆ randn()
Generate a vector of standard normal random numbers.
- Parameters
-
- Returns
- 1D array of i.i.d. N(0,1) samples
◆ random_seed()
| void random_seed |
( |
unsigned |
seed | ) |
|
|
inline |
Seed the global random number generator.
- Parameters
-
◆ stack()
| Arr stack |
( |
const Arr & |
a, |
|
|
const Arr & |
b, |
|
|
int |
= 0 |
|
) |
| |
|
inline |
Stack two 1D arrays as rows into a 2D matrix.
- Parameters
-
- Returns
- 2D matrix with two rows
◆ trace()
| double trace |
( |
const Arr & |
a | ) |
|
|
inline |
Compute the trace of a square matrix (sum of diagonal elements).
\( \operatorname{tr}(A) = \sum_{i=1}^{n} A_{ii} \)
- Parameters
-
- Returns
- Trace value
◆ transpose()
| Arr transpose |
( |
const Arr & |
a | ) |
|
|
inline |
Transpose a 2D matrix.
Minimal linear algebra helpers for Arr, replacing xtensor-blas operations. For small FIR/correlation problems, naive O(n^3) is sufficient.
\[
(A^T)_{ij} = A_{ji}
\]
- Parameters
-
- Returns
- Transposed matrix