[adegenet-commits] r791 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 8 16:02:49 CET 2011
Author: jombart
Date: 2011-02-08 16:02:48 +0100 (Tue, 08 Feb 2011)
New Revision: 791
Modified:
pkg/src/SNPbin.c
Log:
first complete version of dot prod in C for genlightC class.
needs testing and likely (massive) debugging.
Modified: pkg/src/SNPbin.c
===================================================================
--- pkg/src/SNPbin.c 2011-02-08 14:51:16 UTC (rev 790)
+++ pkg/src/SNPbin.c 2011-02-08 15:02:48 UTC (rev 791)
@@ -262,7 +262,7 @@
/* Function to compute one dot products between two individuals */
/* centring and scaling is always used */
/* but need to pass vectors of 0 and 1*/
-double snpbin_dotprod(struct snpbin *x, struct snpbin *y, double *mean, double*sd){
+double snpbin_dotprod(struct snpbin *x, struct snpbin *y, double *mean, double *sd){
/* define variables, allocate memory */
int P = nLoc(x), i, *vecx, *vecy;
short int isna;
@@ -290,7 +290,7 @@
-/* Function to convert a 'genlight' object (R side ) into an array of 'snpbin' (C side) */
+/* Function to convert a 'genlight' object (R side) into an array of 'snpbin' (C side) */
/* Each component of the genlight is concatenated into a single vector */
/* and then used to create different 'snpbin' on the C side */
struct genlightC genlightTogenlightC(unsigned char *gen, int *nbvecperind, int *byteveclength, int *nbnaperind, int *naposi, int *nind, int *nloc){
@@ -317,12 +317,24 @@
/* Function to compute all dot products between individuals */
/* centring and scaling is always used */
/* but need to pass vectors of 0 and 1*/
-void GLdotProd(unsigned char *gen, int *nbvecperind, int *nbnaperind, int *naposi, int *nind, int *nloc, double *res){
-
+void GLdotProd(unsigned char *gen, int *nbvecperind, int *byteveclength, int *nbnaperind, int *naposi, int *nind, int *nloc, double *mean, double *sd, double *res){
+ struct genlightC dat;
+ int i, j, k=0;
+
+ dat = genlightTogenlightC(gen, nbvecperind, byteveclength, nbnaperind, naposi, nind, nloc);
+
+ for(i=0; i< (*nind-1); i++){
+ for(j=i+1; j< *nind; j++){
+ res[k] = snpbin_dotprod(&dat.x[i], &dat.x[j], mean, sd);
+ ++k;
+ }
+ }
}
+
+
/*
=========================
=== TESTING FUNCTIONS ===
More information about the adegenet-commits
mailing list