コード例 #1
0
ファイル: dfa.c プロジェクト: RobDurfee/Code
main(int argc, char **argv)
{
    int i, sw = 0;
    long minbox = 0L, maxbox = 0L, npts, temp;

    /* Read and interpret the command line. */
    pname = argv[0];
    for (i = 1; i < argc && *argv[i] == '-'; i++) {
      switch(argv[i][1]) {
        case 'd':	/* set nfit (the order of the regression fit) */
	  if ((nfit = atoi(argv[++i])+1) < 2)
	      error("order must be greater than 0");
	  break;
	case 'i':	/* input data are already integrated */
	  iflag = 0; break;
	case 'l':	/* set minbox (the minimum box size) */
	  minbox = atol(argv[++i]); break;
	case 'u':	/* set maxbox (the maximum box size) */
	  maxbox = atol(argv[++i]); break;
	case 's':	/* enable sliding window mode */
	  sw = 1; break;
        case 'h':	/* print usage information and quit */
        default:
	  help();
	  exit(1);
      }
    }
  
    /* Allocate and fill the input data array seq[]. */
    npts = input();

    /* Set minimum and maximum box sizes. */
    if (minbox < 2*nfit) minbox = 2*nfit;
    if (maxbox == 0 || maxbox > npts/4) maxbox = npts/4;
    if (minbox > maxbox) {
	SWAP(minbox, maxbox);
	if (minbox < 2*nfit) minbox = 2*nfit;
    }

    /* Allocate and fill the box size array rs[].  rscale's third argument
       specifies that the ratio between successive box sizes is 2^(1/8). */
    nr = rscale(minbox, maxbox, pow(2.0, 1.0/8.0));

    /* Allocate memory for dfa() and the functions it calls. */
    setup();

    /* Measure the fluctuations of the detrended input data at each box size
       using the DFA algorithm; fill mse[] with these results. */
    dfa(seq, npts, nfit, rs, nr, sw);

    /* Output the results. */
    for (i = 1; i <= nr; i++)
	printf("%g\n", log10(mse[i])/2.0);

    /* Release allocated memory. */
    cleanup();
    exit(0);
}
コード例 #2
0
ファイル: intersect.cpp プロジェクト: bribovich/pathtrace
// build accelerator
BVHAccelerator* make_accelerator(vector<range3f>& bboxes) {
    vector<pair<range3f,int>> boxed_prims(bboxes.size());
    for(auto i : range(bboxes.size())) boxed_prims[i] = pair<range3f,int>(rscale(bboxes[i],1+BVHAccelerator_epsilon),i);
    auto bvh = new BVHAccelerator();
    bvh->nodes.push_back(BVHNode());
    make_accelerator_node(0, boxed_prims, bvh->nodes, 0, bboxes.size());
    bvh->prims.reserve(bboxes.size());
    for(auto i : range(boxed_prims.size())) bvh->prims[i] = boxed_prims[i].second;
    return bvh;
}