swh:1:snp:ffdd0a7d2c8ea15ad41d45b3b178f668bd942287
Raw File
Tip revision: 576ff4b7a130640e672f054885dfc219c17aeb2f authored by Derek Young on 29 September 2009, 00:00:00 UTC
version 0.4.3
Tip revision: 576ff4b
z.c
#include <Rmath.h>
#include <R.h>
#include <Rinternals.h>

void newz (int *n, int *k, double *V, double *W, double *z) {
  int i, j, l, ind1, ind2, nn=*n, kk=*k;
  double sum;
  
  for(i=0; i< nn; i++) {
    for(j=0; j< kk; j++) {
      sum=1.0;
      ind1 = i + nn * j;
      for(l = 0; l < kk; l++) {
        if (l != j) {
          ind2 = i + nn * l;
          sum += V[ind2]/V[ind1]*exp(W[ind1]-W[ind2]);
        }
      }
      z[ind1] = 1.0/sum;  
    }
  } 
}

back to top