summaryrefslogtreecommitdiff
path: root/Numeric/CODA/PCA.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Numeric/CODA/PCA.hs')
-rw-r--r--Numeric/CODA/PCA.hs13
1 files changed, 8 insertions, 5 deletions
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));