Browse code

Adding crlmm package

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/crlmm@36653 bc3139a8-67e5-0310-9ffc-ced21a209358

Benilton Carvalho authored on 14/01/2009 22:00:52
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+#include <math.h>
2
+#include <R.h>
3
+#include <Rdefines.h>
4
+#include <Rmath.h>
5
+#include <Rinternals.h>
6
+
7
+#include "utils.h"
8
+
9
+SEXP R_trimmed_stats(SEXP X, SEXP Y, SEXP trim){
10
+  SEXP dim1;
11
+  SEXP estimates1, estimates2, estimates3, output;
12
+  double *Xptr, *Mptr1, *Mptr2, *Mptr3, *Tptr;
13
+  int *Yptr;
14
+  int rows, cols;
15
+
16
+  PROTECT(dim1 = getAttrib(X,R_DimSymbol));
17
+  rows = INTEGER(dim1)[0];
18
+  cols = INTEGER(dim1)[1];
19
+  
20
+  Xptr = NUMERIC_POINTER(AS_NUMERIC(X));
21
+  Yptr = INTEGER_POINTER(AS_INTEGER(Y));
22
+  Tptr = NUMERIC_POINTER(AS_NUMERIC(trim));
23
+
24
+  PROTECT(estimates1 = allocMatrix(REALSXP, rows, 3));
25
+  PROTECT(estimates2 = allocMatrix(REALSXP, rows, 3));
26
+  PROTECT(estimates3 = allocMatrix(REALSXP, rows, 3));
27
+  
28
+  Mptr1 = NUMERIC_POINTER(estimates1);
29
+  Mptr2 = NUMERIC_POINTER(estimates2);
30
+  Mptr3 = NUMERIC_POINTER(estimates3);
31
+  
32
+  trimmed_stats(Xptr, Mptr1, Mptr2, Mptr3, Yptr, rows, cols, Tptr);
33
+
34
+  PROTECT(output = allocVector(VECSXP,3));
35
+  SET_VECTOR_ELT(output, 0, estimates1);
36
+  SET_VECTOR_ELT(output, 1, estimates2);
37
+  SET_VECTOR_ELT(output, 2, estimates3);
38
+
39
+  UNPROTECT(5);
40
+  
41
+  return output;
42
+
43
+}