From 42edc4f3b5dcd460aef75af536ee541c975b0e8b Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 9 Feb 2023 09:36:19 +1100 Subject: allow setting number of iterations for optimiser --- Numeric/CODA/PCA.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Numeric/CODA') diff --git a/Numeric/CODA/PCA.hs b/Numeric/CODA/PCA.hs index 01fa3f1..903a166 100644 --- a/Numeric/CODA/PCA.hs +++ b/Numeric/CODA/PCA.hs @@ -40,19 +40,22 @@ C.include "<../../../pca.h>" -- | Decomposes a non-negative matrix into the specified number components on the CoDA simplex -- via Bregman divergences pca :: - -- | An optional quantile to use as the reference; defaults to 0.5 - Maybe Double -> + -- | Number of iterations + Int -> + -- | Quantile to use as the reference + Double -> -- | number of components to decompose into Int -> -- | matrix to decompose Matrix Double -> PCA -pca q k x = unsafePerformIO $ do +pca iters q k x = unsafePerformIO $ do let (n, m) = size x + iters' = fromIntegral iters k' = fromIntegral k n' = fromIntegral n m' = fromIntegral m - q' = realToFrac $ fromMaybe 0.5 q + q' = realToFrac q b <- VM.new (n * k) c <- VM.new (m * k) y <- VM.new (n * m) @@ -70,7 +73,7 @@ pca q k x = unsafePerformIO $ do struct futhark_f64_2d *Bf; struct futhark_f64_2d *Uf; - futhark_entry_pcaWithQuantile(ctx, &Bf, &Uf, &Yf, $(double *lptr), $(double q'), $(int k'), Xf); + futhark_entry_pcaWithQuantile(ctx, &Bf, &Uf, &Yf, $(double *lptr), $(int iters'), $(double q'), $(int k'), Xf); futhark_context_sync(ctx); futhark_values_f64_2d(ctx, Bf, $(double *bptr)); futhark_values_f64_2d(ctx, Uf, $(double *cptr)); -- cgit v1.2.3