Пример #1
0
double dofstxx(double *fstans, double *fstsd, SNP **xsnplist, int *xindex, int *xtypes, 
   int nrows, int ncols, int numeg, double blgsize, SNP **snpmarkers, Indiv **indm) 

{

   int t1, t2 ;
   int nblocks, xnblocks ;  
   double y, sd ; 
   int *blstart, *blsize ;
   double *xfst ;

  nblocks = numblocks(snpmarkers, numsnps, blgsize) ;

  ZALLOC(blstart, nblocks, int) ;
  ZALLOC(blsize, nblocks, int) ;
  ZALLOC(xfst, numeg*numeg, double) ;

  printf("number of blocks for moving block jackknife: %d\n", nblocks) ;

  setblocks(blstart, blsize, &xnblocks, xsnplist, ncols, blgsize)  ;
  fixwt(xsnplist, ncols, 1.0) ;

  dofstnumx(xfst, fstans, fstsd, xsnplist, xindex, xtypes,  
   nrows, ncols, numeg, nblocks, indm, YES) ;

  free(blstart) ; 
  free(blsize)  ; 
  free(xfst)  ;

}
Пример #2
0
/* dynamically allocate the tree */
static int
allocate_tree(merkletree_t *tree, uint64_t size, size_t h)
{
	Rows	*rows = (Rows *)tree->rows;

	if (h == 0) {
		rows->row[h].outc = size;
	}
	rows->row[h].blocks = numblocks(size, tree->blocksize);
	rows->row[h].out = calloc(1, rows->row[h].blocks * tree->rawoutsize);
	if (size > 0 && rows->row[h].blocks > 1) {
		return allocate_tree(tree, size / (tree->blocksize * tree->rawoutsize), ++rows->height);
	}
	return (int)++rows->height;
}
Пример #3
0
void write_test(char *dev, unsigned int blocks, int blocksize, int repeats)
{
	int fd;
	int size;
	char buffer[blocksize];
	unsigned int towrite;
	unsigned int start_time;
	unsigned int end_time;
	unsigned int time_taken;
	int i;
	float bps;

	for(size=0; size<blocksize; size++)
	{
		buffer[size]=size;
	}

	fd = open(dev,O_RDWR);

	if(!fd)
	{
		printf("Error: unable to open %s for writing.\n",dev);
		exit(10);
	}
	size = numblocks(fd);
	if(size==0)
	{
		printf("Error: unable to get media size.\n");
		close(fd);
		exit(0);
	}
	if(blocks>size)
	{
		printf("More blocks requested than media size.  Reducing.\n");
		blocks = size;
	}
	if(blocks==0)
	{
		blocks=size;
	}

	printf("Testing write of %s from 0 to %d with %d byte blocks...\n",
		dev,blocks-1,blocksize);

	start_time = msec();
	for(i=0; i<repeats; i++)
	{
		lseek(fd,0,SEEK_SET);
		towrite = blocks * 1024;
		while(towrite > 0)
		{
			if(towrite>blocksize)
			{
				towrite -= write(fd,buffer,blocksize);
			} else {
				towrite -= write(fd,buffer,towrite);
			}
		}
	}
	end_time = msec();
	close(fd);
	time_taken = end_time - start_time;
        bps = (float)((blocks*repeats) * 1024) / ((float)time_taken / 1000.0);

        printf("Time taken: %f seconds.  Speed: %f KBytes/second\n",
                time_taken / 1000.0, bps/1024.0);
}