summaryrefslogtreecommitdiff
path: root/R/src/wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'R/src/wrapper.c')
-rw-r--r--R/src/wrapper.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/R/src/wrapper.c b/R/src/wrapper.c
new file mode 100644
index 0000000..dd7bce1
--- /dev/null
+++ b/R/src/wrapper.c
@@ -0,0 +1,27 @@
+#include "pca.h"
+
+void
+pca_wrapper(int *n, int *d, 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);
+
+ struct futhark_f64_2d *Xf = futhark_new_f64_2d(ctx, X, *n, *d);
+ struct futhark_f64_2d *Yf;
+ struct futhark_f64_2d *Bf;
+ struct futhark_f64_2d *Uf;
+
+ futhark_entry_pcaWithQuantile(ctx, &Bf, &Uf, &Yf, l, *q, *k, Xf);
+ futhark_context_sync(ctx);
+ futhark_values_f64_2d(ctx, Bf, B);
+ futhark_values_f64_2d(ctx, Uf, U);
+ futhark_values_f64_2d(ctx, Yf, X);
+
+ futhark_free_f64_2d(ctx, Xf);
+ futhark_free_f64_2d(ctx, Bf);
+ futhark_free_f64_2d(ctx, Uf);
+ futhark_free_f64_2d(ctx, Yf);
+ futhark_context_free(ctx);
+ futhark_context_config_free(cfg);
+
+}