From 40d377b86c856f5a4510a6f5cd56be004873ad77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20M=C3=BCller?= Date: Mon, 12 Oct 2020 21:30:12 +0200 Subject: [PATCH] Remove defunct rgb_operm [Retrieved from: https://github.com/eddelbuettel/dieharder/pull/2/commits/40d377b86c856f5a4510a6f5cd56be004873ad77] Signed-off-by: Fabrice Fontaine --- include/Makefile.am | 1 - include/dieharder/rgb_operm.h | 38 -- include/dieharder/tests.h | 2 - libdieharder/rgb_operm.c | 633 ---------------------------------- 4 files changed, 674 deletions(-) delete mode 100644 include/dieharder/rgb_operm.h delete mode 100644 libdieharder/rgb_operm.c diff --git a/include/Makefile.am b/include/Makefile.am index f80b4ff..e4659cd 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -33,7 +33,6 @@ nobase_include_HEADERS = dieharder/copyright.h \ dieharder/rgb_lagged_sums.h \ dieharder/rgb_lmn.h \ dieharder/rgb_minimum_distance.h \ - dieharder/rgb_operm.h \ dieharder/rgb_persist.h \ dieharder/rgb_permutations.h \ dieharder/rgb_timing.h \ diff --git a/include/dieharder/rgb_operm.h b/include/dieharder/rgb_operm.h deleted file mode 100644 index c48fa37..0000000 --- a/include/dieharder/rgb_operm.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * rgb_operm test header. - */ - -/* - * function prototype - */ -int rgb_operm(Test **test,int irun); - -static Dtest rgb_operm_dtest __attribute__((unused)) = { - "RGB Overlapping Permuations Test", - "rgb_operm", - "\n\ -#========================================================================\n\ -# RGB Overlapping Permutations Test\n\ -# Forms both the exact (expected) covariance matrix for overlapping\n\ -# permutations of random integer and an empirical covariance matrix\n\ -# formed from a long string of samples. The difference is expected\n\ -# to have a chisq distribution and hence can be transformed into a\n\ -# sample p-value. Note that this is one possible functional replacement\n\ -# for the broken/defunct diehard operm5 test, but one that permits k (the\n\ -# number of numbers in the overlapping permutation window) to be varied\n\ -# from 2 to perhaps 8.\n\ -#\n", - 100, /* Default psamples */ - 100000, /* Default tsamples */ - 1, /* We magically make all the bit tests return a single histogram */ - rgb_operm, - 0 -}; - -/* - * Global variables. - * - * rgb_operm_k is the size of the overlapping window that is slid along - * a data stream of rands from x_i to x_{i+k} to compute c[][]. - */ -unsigned int rgb_operm_k; diff --git a/include/dieharder/tests.h b/include/dieharder/tests.h index 1674aed..b50dbe3 100644 --- a/include/dieharder/tests.h +++ b/include/dieharder/tests.h @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -80,7 +79,6 @@ RGB_PERMUTATIONS, RGB_LAGGED_SUMS, RGB_LMN, - RGB_OPERM, DAB_BYTEDISTRIB, DAB_DCT, DAB_FILLTREE, diff --git a/libdieharder/rgb_operm.c b/libdieharder/rgb_operm.c deleted file mode 100644 index 15f8e9a..0000000 --- a/libdieharder/rgb_operm.c +++ /dev/null @@ -1,633 +0,0 @@ -/* - * ======================================================================== - * $Id: rgb_operm.c 252 2006-10-10 13:17:36Z rgb $ - * - * See copyright in copyright.h and the accompanying file COPYING - * ======================================================================== - */ - -/* - * ======================================================================== - * This is the revised Overlapping Permutations test. It directly - * simulates the covariance matrix of overlapping permutations. The way - * this works below (tentatively) is: - * - * For a bit ntuple of length N, slide a window of length N to the - * right one bit at a time. Compute the permutation index of the - * original ntuple, the permutation index of the window ntuple, and - * accumulate the covariance matrix of the two positions. This - * can be directly and precisely computed as well. The simulated - * result should be distributed according to the chisq distribution, - * so we subtract the two and feed it into the chisq program as a - * vector to compute p. - * - * This MAY NOT BE RIGHT. I'm working from both Marsaglia's limited - * documentation (in a program that doesn't do ANYTHING like what the - * documentation says it does) and from Nilpotent Markov Processes. - * But I confess to not quite understand how to actually perform the - * test in the latter -- it is very good at describing the construction - * of the target matrix, not so good at describing how to transform - * this into a chisq and p. - * - * FWIW, as I get something that actually works here, I'm going to - * THOROUGHLY document it in the book that will accompany the test. - *======================================================================== - */ - -#include -#define RGB_OPERM_KMAX 10 - -/* - * Some globals that will eventually go in the test include where they - * arguably belong. - */ -double fpipi(int pi1,int pi2,int nkp); -uint piperm(size_t *data,int len); -void make_cexact(); -void make_cexpt(); -int nperms,noperms; -double **cexact,**ceinv,**cexpt,**idty; -double *cvexact,*cvein,*cvexpt,*vidty; - -int rgb_operm(Test **test,int irun) -{ - - int i,j,n,nb,iv,s; - uint csamples; /* rgb_operm_k^2 is vector size of cov matrix */ - uint *count,ctotal; /* counters */ - uint size; - double pvalue,ntuple_prob,pbin; /* probabilities */ - Vtest *vtest; /* Chisq entry vector */ - - gsl_matrix_view CEXACT,CEINV,CEXPT,IDTY; - - /* - * For a given n = ntuple size in bits, there are n! bit orderings - */ - MYDEBUG(D_RGB_OPERM){ - printf("#==================================================================\n"); - printf("# rgb_operm: Running rgb_operm verbosely for k = %d.\n",rgb_operm_k); - printf("# rgb_operm: Use -v = %d to focus.\n",D_RGB_OPERM); - printf("# rgb_operm: ======================================================\n"); - } - - /* - * Sanity check first - */ - if((rgb_operm_k < 0) || (rgb_operm_k > RGB_OPERM_KMAX)){ - printf("\nError: rgb_operm_k must be a positive integer <= %u. Exiting.\n",RGB_OPERM_KMAX); - exit(0); - } - - nperms = gsl_sf_fact(rgb_operm_k); - noperms = gsl_sf_fact(3*rgb_operm_k-2); - csamples = rgb_operm_k*rgb_operm_k; - gsl_permutation * p = gsl_permutation_alloc(nperms); - - /* - * Allocate memory for value_max vector of Vtest structs and counts, - * PER TEST. Note that we must free both of these when we are done - * or leak. - */ - vtest = (Vtest *)malloc(csamples*sizeof(Vtest)); - count = (uint *)malloc(csamples*sizeof(uint)); - Vtest_create(vtest,csamples+1); - - /* - * We have to allocate and free the cexact and cexpt matrices here - * or they'll be forgotten when these routines return. - */ - MYDEBUG(D_RGB_OPERM){ - printf("# rgb_operm: Creating and zeroing cexact[][] and cexpt[][].\n"); - } - cexact = (double **)malloc(nperms*sizeof(double*)); - ceinv = (double **)malloc(nperms*sizeof(double*)); - cexpt = (double **)malloc(nperms*sizeof(double*)); - idty = (double **)malloc(nperms*sizeof(double*)); - cvexact = (double *)malloc(nperms*nperms*sizeof(double)); - cvein = (double *)malloc(nperms*nperms*sizeof(double)); - cvexpt = (double *)malloc(nperms*nperms*sizeof(double)); - vidty = (double *)malloc(nperms*nperms*sizeof(double)); - for(i=0;idata[k]; - - /* Not cruft, but quiet... - MYDEBUG(D_RGB_OPERM){ - printf("#------------------------------------------------------------------\n"); - printf("# Generating offset sample permutation pi's\n"); - } - */ - for(k=0;k<2*rgb_operm_k - 1;k++){ - gsl_sort_index((size_t *) ps,&testv[k],1,rgb_operm_k); - pi[k] = piperm((size_t *) ps,rgb_operm_k); - - /* Not cruft, but quiet... - MYDEBUG(D_RGB_OPERM){ - printf("# %u: ",k); - for(ip=k;ipdata[ip]); - } - printf(" = %u\n",pi[k]); - } - */ - } - - /* - * This is the business end of things. The covariance matrix is the - * the sum of a central function of the permutation indices that yields - * nperms-1/nperms on diagonal, -1/nperms off diagonal, for all the - * possible permutations, for the FIRST permutation in a sample (fi) - * times the sum of the same function over all the overlapping permutations - * drawn from the same sample. Quite simple, really. - */ - for(i=0;idata[rgb_operm_k-j-1] = lookup[i]->data[j]; - } - } else { - gsl_permutation_memcpy(lookup[i],lookup[i-1]); - gsl_permutation_next(lookup[i]); - for(j=0;jdata[rgb_operm_k-j-1] = lookup[i]->data[j]; - } - } - } - */ - MYDEBUG(D_RGB_OPERM){ - for(i=0;i ",i); - gsl_permutation_fprintf(stdout,lookup[i]," %u"); - printf("\n"); - } - } - - } - - for(i=0;idata,len*sizeof(uint))==0){ - /* Not cruft, but off: - MYDEBUG(D_RGB_OPERM){ - printf("# piperm(): "); - gsl_permutation_fprintf(stdout,lookup[i]," %u"); - printf(" = %u\n",i); - } - */ - return(i); - } - } - printf("We'd better not get here...\n"); - - return(0); - -} - -double fpipi(int pi1,int pi2,int nkp) -{ - - int i; - double fret; - - /* - * compute the k-permutation index from iperm for the window - * at data[offset] of length len. If it matches pind, return - * the first quantity, otherwise return the second. - */ - if(pi1 == pi2){ - - fret = (double) (nkp - 1.0)/nkp; - if(verbose < 0){ - printf(" f(%d,%d) = %10.6f\n",pi1,pi2,fret); - } - return(fret); - - } else { - - fret = (double) (-1.0/nkp); - if(verbose < 0){ - printf(" f(%d,%d) = %10.6f\n",pi1,pi2,fret); - } - return(fret); - - } - - -} - - - -