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 --- R/R/pca.R | 3 ++- R/src/wrapper.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'R') diff --git a/R/R/pca.R b/R/R/pca.R index 85782e4..7d0d742 100644 --- a/R/R/pca.R +++ b/R/R/pca.R @@ -1,4 +1,4 @@ -pca <- function(x, k=1,q=0.5){ +pca <- function(x, k=1, q=0.5, iters=10000){ n <- nrow(x) d <- ncol(x) B <- matrix(0, n, k) @@ -8,6 +8,7 @@ pca <- function(x, k=1,q=0.5){ res <- .C("pca_wrapper", n=as.integer(n), d=as.integer(d), + iters=as.integer(iters), q=as.numeric(q), k=as.integer(k), X=as.numeric(t(x)), diff --git a/R/src/wrapper.c b/R/src/wrapper.c index dd7bce1..52c1192 100644 --- a/R/src/wrapper.c +++ b/R/src/wrapper.c @@ -1,7 +1,7 @@ #include "pca.h" void -pca_wrapper(int *n, int *d, double *q, int *k, double *X, double *B, double *U, double *l) { +pca_wrapper(int *n, int *d, int *iters, double *q, int *k, double *X, double *B, double *U, double *l) { struct futhark_context_config *cfg = futhark_context_config_new(); struct futhark_context *ctx = futhark_context_new(cfg); @@ -11,7 +11,7 @@ pca_wrapper(int *n, int *d, double *q, int *k, double *X, double *B, double *U, struct futhark_f64_2d *Bf; struct futhark_f64_2d *Uf; - futhark_entry_pcaWithQuantile(ctx, &Bf, &Uf, &Yf, l, *q, *k, Xf); + futhark_entry_pcaWithQuantile(ctx, &Bf, &Uf, &Yf, l, *iters, *q, *k, Xf); futhark_context_sync(ctx); futhark_values_f64_2d(ctx, Bf, B); futhark_values_f64_2d(ctx, Uf, U); -- cgit v1.2.3