| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.PCA.Lin
Description
Linear array ops for PCA: center, Gram (dagger-compose), BLAS mult.
Data layout is always samples × features (rows = observations).
The dagger promise used here is the array transpose: covariance on the
feature side is X† X via transpose-compose (up to scaling). Spectral
work is delegated to hmatrix (same bridge pattern as Harpie.Hmatrix,
which is flag-gated in harpie).
Synopsis
- nSamples :: Array Double -> Int
- nFeatures :: Array Double -> Int
- columnMeans :: Array Double -> Array Double
- centerColumns :: Array Double -> (Array Double, Array Double)
- gramFeatures :: Array Double -> Array Double
- multM :: Array Double -> Array Double -> Array Double
- transpose2 :: Array Double -> Array Double
- toMatrix :: Array Double -> Maybe (Matrix Double)
- fromMatrix :: Matrix Double -> Array Double
Layout
Center
centerColumns :: Array Double -> (Array Double, Array Double) Source #
Center columns; returns (centered, means).
Dagger-compose
gramFeatures :: Array Double -> Array Double Source #
Feature Gram matrix X† X (features × features), unnormalised.
Dagger-compose: reverse wire is transpose, compose is BLAS mult.
Scale by 1/(n-1) for sample covariance if desired.
BLAS
multM :: Array Double -> Array Double -> Array Double Source #
BLAS matrix multiply for rank-2 arrays.