# PDL::MatrixOps
📦 stdpdl
## Synopsis
```none
use PDL;
use PDL::MatrixOps;
my $m = pdl [[1,2],[3,4]];
my $d = det($m);
my $inv = inv($m);
```
## Functions
### Other Functions
#### `identity`
`identity($n_or_pdl)` — create an NxN identity matrix. If given a PDL, uses its first dim; if given a scalar, uses it directly.
#### `trace`
`trace($matrix)` — sum of diagonal elements of a square matrix
#### `norm`
`norm($matrix)` — Frobenius norm of a matrix
#### `det`
`det($matrix)` — determinant of a square matrix (via LU decomposition). Supports broadcasting: if input has dims [N,N,…], computes determinant for each NxN slice, returning a PDL of shape […].
#### `inv`
`inv($matrix [, {s=>1}])` — inverse of a square matrix (via Gauss-Jordan elimination). With {s=>1} option, returns undef instead of croaking on singular matrix.
#### `lu_decomp`
`lu_decomp($matrix)` — LU decomposition, returns (`$LU`, `$perm`, `$sign`)
#### `lu_backsub`
`lu_backsub($LU, $perm, $b)` — solve Ax=b from LU decomposition
#### `simq`
`simq($a, $b)` — solve simultaneous linear equations Ax=b
#### `eigens_sym`
`eigens_sym($matrix)` — eigenvalues and eigenvectors of a real symmetric matrix. Uses the Jacobi eigenvalue algorithm. Returns (`$eigenvectors`, `$eigenvalues`).
#### `eigens`
`eigens($matrix)` — eigenvalues and eigenvectors of a general real matrix. For symmetric matrices delegates to eigens_sym logic. For non-symmetric, uses QR algorithm (simplified). Returns (`$eigenvectors`, `$eigenvalues`).
#### `stretcher`
`stretcher($diag_pdl)` — create diagonal matrix(es) from a PDL. 1D input [a,b] → 2x2 diagonal. 2D input [N,M] → NxNxM broadcasted diagonals.
#### `svd`
`svd($matrix)` — Singular Value Decomposition. Returns (`$U`, `$S`, `$V`) where `$matrix` = `$U` \* `diag($S)` \* `$V`^T. Uses one-sided Jacobi SVD algorithm.