Skip to content

Commit

Permalink
version 0.99.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Boenn authored and gaborcsardi committed Jun 16, 2014
1 parent 5d3842b commit 9e19e07
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 62 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: hypergea
Type: Package
Title: Hypergeometric tests
Version: 0.99.4
Version: 0.99.5
Date: 2014-06-16
Author: Markus Boenn
Maintainer: Markus Boenn <markus.boenn@ufz.de>
Expand All @@ -10,7 +10,7 @@ License: GPL (>= 2)
Depends: R (>= 3.0.0)
Imports:
SystemRequirements: OpenMP (>=3.0)
Packaged: 2014-06-20 11:06:13 UTC; boenn
Packaged: 2014-06-20 13:40:25 UTC; boenn
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2014-06-20 13:22:32
Date/Publication: 2014-06-22 10:14:00
8 changes: 4 additions & 4 deletions MD5
@@ -1,4 +1,4 @@
aff1a2bb822168a3ea44b5ae2c62025f *DESCRIPTION
27dfa67ba0a722db5a354067e43bbd26 *DESCRIPTION
293f400a25b859fd72ab7cf29cecf504 *NAMESPACE
5688b42144d0c391b9c0fedf1ca84a42 *R/getExpectedValues.R
1cd7d02250140f5492957a47d6564d5f *R/getMargins.R
Expand All @@ -12,6 +12,6 @@ e959fdd323943118f32bc5007abd9aa5 *man/getOddsRatio.Rd
d2cec03a29d68371ab487aec59927f33 *man/hypergea-package.Rd
e8c34e7f3a814a1a505656564a062702 *man/hypergeom.test.Rd
bf7e140fc030043484ca8d2e096baba8 *src/Makevars
2d7662a79cce84359ac8fafc4803159e *src/hypergeom_2x2x2.cpp
4dc4c5a443cbb191131998165d0c9fd2 *src/hypergeom_IxJ.cpp
29bc6f5fdac97159877f9221d5b762ff *src/lfactorial.c
ed6975ddc461ab755fe08e689e4a453c *src/hypergeom_2x2x2.cpp
30ce54c8dc17faa0dc551a86515518db *src/hypergeom_IxJ.cpp
7bebcd374a03cda3e264aa333eee1f9c *src/lfactorial.c
22 changes: 1 addition & 21 deletions src/hypergeom_2x2x2.cpp
Expand Up @@ -4,25 +4,13 @@
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <R_ext/Utils.h> /* for R_CheckUserInterrupt() */
#include <R_ext/Boolean.h> /* for R_CheckUserInterrupt() */

#ifdef _OPENMP
#include <omp.h>
#endif

#define ULONGLONG uint64_t

Rboolean R_ToplevelExec(void (*fun)(void *), void *data);

static void chkIntFn(void *dummy) {
R_CheckUserInterrupt();
}
// this will call the above in a top-level context so it won't longjmp-out of your context
int checkInterrupt() {
return((int)(R_ToplevelExec(chkIntFn, NULL) == FALSE));
}


extern "C"
void hypergeom_2x2x2(int *O000, int *N, int *marg, int *margins, double *p0, double *n0, double *Prob, double *Freq, double *Hist_n000, int *nthreads){
Expand All @@ -45,7 +33,6 @@ void hypergeom_2x2x2(int *O000, int *N, int *marg, int *margins, double *p0, dou
//results
double probTables[4];

//unsigned long long countTables[4];
ULONGLONG countTables[4];
ULONGLONG nO000=0;
//unsigned long long hist_n000[min_margin+1];
Expand All @@ -54,7 +41,7 @@ void hypergeom_2x2x2(int *O000, int *N, int *marg, int *margins, double *p0, dou

preCalcFact[0]=0;
for( h=1; h<= NN; h++){
preCalcFact[h]=preCalcFact[h-1]+log(h);
preCalcFact[h]=preCalcFact[h-1]+log((double)h);
}
lfN=2.0*preCalcFact[NN];
lfmargins[0]=preCalcFact[ margins[0] ] + preCalcFact[ margins[1] ];
Expand Down Expand Up @@ -93,8 +80,6 @@ void hypergeom_2x2x2(int *O000, int *N, int *marg, int *margins, double *p0, dou
#pragma omp for schedule(dynamic)
for( i1=0; i1<=minAtFirstPosition; ++i1 ){

if( FLAG_interrupt ){ continue; }

int x[2][2][2];
x[0][0][0]= -1;
x[1][0][0]= -1;
Expand All @@ -116,11 +101,6 @@ void hypergeom_2x2x2(int *O000, int *N, int *marg, int *margins, double *p0, dou
int minSecondLoop=(marg[0] - x[0][0][0] );
for( i2=0; i2<=minSecondLoop; ++i2 ){

if( FLAG_interrupt ){ break; }
if( (this_thread == 0) && (((++interrupt_counter) & 262143) == 0) && (checkInterrupt()==1) ){ //check if thread is master to check for user interrupt
FLAG_interrupt=1; break;
}

x[0][0][1]=i2;

double lm2=preCalcFact[ x[0][0][1] ];
Expand Down
33 changes: 1 addition & 32 deletions src/hypergeom_IxJ.cpp
Expand Up @@ -4,33 +4,17 @@
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
//#include <string.h>
#include <R_ext/Utils.h> /* for R_CheckUserInterrupt() */
#include <R_ext/Boolean.h> /* for R_CheckUserInterrupt() */

#ifdef _OPENMP
#include <omp.h>
#endif

#define ULONGLONG uint64_t

Rboolean R_ToplevelExec(void (*fun)(void *), void *data);
int checkInterrupt(void);
static void chkIntFn(void *);
int FLAG_interrupt=0;
ULONGLONG interrupt_counter=0;


extern "C"
void rec(int **x, int *dim, int *pos, int *margins, ULONGLONG *local_countTables, double *local_probTables, ULONGLONG *local_nO000, double *preCalcFact, int *rowsums, int *colsums, double diff_lfmarginsTotal_lfN, int *O000, double *p0, int this_thread){

if(FLAG_interrupt){return;} //2**18-1
if( this_thread == 0 && (((++interrupt_counter) & 262143) == 0 ) && (checkInterrupt()==1)){ //check if thread is master to check for user interrupt
FLAG_interrupt=1; interrupt_counter=0; return;
}
if(interrupt_counter > 1000000000){interrupt_counter=0;}


int some_columns_left=0;
int current_row=pos[0];
int current_col=pos[1];
Expand Down Expand Up @@ -124,7 +108,7 @@ void hypergeom_IxJ(int *O000, int *N, int *margins, double *p0, double *n0, doub
for( h=0; h<4; h++ ){ countTables[h]=0; probTables[h]=0.0; }

preCalcFact[0]=0;
for( h=1; h<= NN; ++h ){ preCalcFact[h]=preCalcFact[h-1]+log(h); }
for( h=1; h<= NN; ++h ){ preCalcFact[h]=preCalcFact[h-1]+log((double)h); }
lfN=preCalcFact[NN];
lfmargins[0]=0.0;
for( h=0; h<dim[0]; ++h ){ lfmargins[0] += preCalcFact[ margins[h] ]; }
Expand All @@ -139,9 +123,6 @@ void hypergeom_IxJ(int *O000, int *N, int *margins, double *p0, double *n0, doub
#endif


// state is stored after last run; re-initialize
FLAG_interrupt=interrupt_counter=0;

int minAtFirstPosition=( (margins[ 0 ] < margins[ dim[1] ]) ? margins[ 0 ] : margins[ dim[1] ] );

int *aux_rowsums=new int[dim[0]];
Expand All @@ -167,18 +148,6 @@ void hypergeom_IxJ(int *O000, int *N, int *margins, double *p0, double *n0, doub
#pragma omp for schedule(dynamic)
for( i1=0; i1<=minAtFirstPosition; ++i1 ){

if(FLAG_interrupt){
#ifdef _OPENMP
continue;
#else
break;
#endif

}
if( (this_thread == 0) && (((++interrupt_counter) & 262143) == 0 ) && (checkInterrupt()==1) ){ //check if thread is master to check for user interrupt
FLAG_interrupt=1; continue;
}

int *pos=new int[2];
int *rowsums=new int[dim[0]];
int *colsums=new int[dim[1]];
Expand Down
4 changes: 2 additions & 2 deletions src/lfactorial.c
Expand Up @@ -18,9 +18,9 @@ void intern_lfactorial( int *xx, int *L, double *r ){
preCalcFact=(double*)malloc((mx+1)*sizeof(double));
preCalcFact[0]=0;
for( l=1; l<= mx; l++){
preCalcFact[l]=preCalcFact[l-1]+log((float)l);
preCalcFact[l]=preCalcFact[l-1]+log((double)l);
l++;
preCalcFact[l]=preCalcFact[l-1]+log((float)l);
preCalcFact[l]=preCalcFact[l-1]+log((double)l);
}

*r=preCalcFact[(int)xx[0]];
Expand Down

0 comments on commit 9e19e07

Please sign in to comment.