• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sf_getbool函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sf_getbool函数的典型用法代码示例。如果您正苦于以下问题:C++ sf_getbool函数的具体用法?C++ sf_getbool怎么用?C++ sf_getbool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sf_getbool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main (int argc, char **argv)
{
    bool verb;                /* verbosity flag */
    bool adj;
    int nt;                   /* number of time samples */
    int nx;                   /* number of offsets */ 
    int nf1, nf2, nf;         /* number of filter size */
    int n3, i3;
    float *x, *y, *filt;      /* input and output */
    sf_file in, out, fil;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");
    fil = sf_input("filt");

    if (!sf_getbool("adj",&adj)) adj=true;
    /* if y, perform adjoint operation */

    if (!sf_getbool ("verb",&verb)) verb=false; /* verbosity flag */

    /* read input file parameters */
    if (!sf_histint(in,"n1",&nt)) sf_error("No n1= in input");
    if (!sf_histint(in,"n2",&nx)) sf_error("No n2= in input");
    n3 = sf_leftsize(in,2);

    if (!sf_histint(fil,"n1",&nf1)) sf_error("No nf1= in filt");
    if (!sf_histint(fil,"n2",&nf2)) sf_error("No nf2= in filt");
    if (!sf_histint(fil,"n3",&nf)) sf_error("No nf3= in filt");

    if (nt != nf1 || nx != nf2 ) sf_error("Nee n1==nf1 && n2==nf2");

    x = sf_floatalloc (nt*nx);
    y = sf_floatalloc (nt*nx);
    filt = sf_floatalloc (nt*nx*nf);

    for (i3=0; i3 < n3; i3++) {
	if(verb) sf_warning("i=%d of %d",i3+1,n3);

	sf_floatread(filt,nt*nx*nf,fil);

	matching_init(filt,nt,nx,nf);

	if (adj) {
	    sf_floatread(y,nt*nx,in);
	} else { /* modeling */
	    sf_floatread(x,nt*nx,in);
	}
    
	pmatching_lop (adj, false, nt*nx, nt*nx, x, y);
	
	if (adj) {
	    sf_floatwrite(x,nt*nx,out);
	} else { /* modeling */
	    sf_floatwrite(y,nt*nx,out);
	}
    }
    
    exit (0);
}
开发者ID:1014511134,项目名称:src,代码行数:60,代码来源:Mtestmatch.c


示例2: main

int main(int argc, char* argv[])
{
    bool adj, verb;
    int n1, n2, n12, n3, i3, order, ns;
    float *input, *smooth, **slope, eps;
    sf_file in, out, dip;

    sf_init(argc,argv);
    in = sf_input("in");
    dip = sf_input("dip");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histint(in,"n2",&n2)) sf_error("No n2= in input");
    n3 = sf_leftsize(in,2);
    n12 = n1*n2;

    if (!sf_getbool("verb",&verb)) verb=false;
    /* verbosity flag */

    if (!sf_getint("ns",&ns)) ns=0;
    /* smoothing radius */

    if (!sf_getbool("adj",&adj)) adj=false;
    /* adjoint flag */

    if (!sf_getfloat("eps",&eps)) eps=0.01;
    /* regularization */

    if (!sf_getint("order",&order)) order=1;
    /* accuracy order */	

    input = sf_floatalloc(n12);
    smooth = sf_floatalloc(n12);
    slope = sf_floatalloc2(n1,n2);

    pwsmooth_init(ns, n1, n2, order, eps);

    for (i3=0; i3 < n3; i3++) {
	if (verb) sf_warning("slice %d of %d;",i3+1,n3);

	sf_floatread(input,n12,in);
	sf_floatread(slope[0],n12,dip);

	pwsmooth_set(slope);

	if (adj) {
	    pwsmooth_lop(true,false,n12,n12,smooth,input);
	} else {
	    pwsmooth_lop(false,false,n12,n12,input,smooth);
	}

	sf_floatwrite(smooth,n12,out);
    }
    if (verb) sf_warning(".");

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:58,代码来源:Mpwsmooth.c


示例3: main

int main(int argc, char* argv[])
{
    int nx, nf, i2, n2, lag, niter;
    bool single, verb;
    float eps;
    sf_complex *xx, *yy, *ff;
    sf_file in, out, filt;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");
    filt = sf_input("filt");

    if (SF_COMPLEX != sf_gettype(in) ||
	SF_COMPLEX != sf_gettype(filt)) sf_error("Need float input");
    if (!sf_histint(in,"n1",&nx)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    if (!sf_histint(filt,"n1",&nf)) sf_error("No n1= in filtin");

    xx = sf_complexalloc(nx);
    ff = sf_complexalloc(nf);

    if (!sf_getbool("single",&single)) single=true;
    /* single channel or multichannel */

    if (!sf_getint("lag",&lag)) lag=1;
    /* lag for internal convolution */

    yy = sf_complexalloc(nx);

    if (!sf_getfloat("eps",&eps)) eps=1.0f;
    /* regularizion parameter */

    if (!sf_getint("niter",&niter)) niter=100;
    /* number of iterations */

    if (!sf_getbool("verb",&verb)) verb=false;
    /* verbosity flag */

    if (!single) sf_complexread (ff,nf,filt);

    for (i2=0; i2 < n2; i2++) {
        if (single) sf_complexread (ff,nf,filt);
        sf_complexread (xx,nx,in);

	cicai1_init(nf,ff,lag);

	sf_csolver_reg(sf_ccopy_lop,sf_ccgstep,cicai1_lop,nx,nx,nx,yy,xx,niter,eps,"verb",verb,"end");
	sf_ccgstep_close();
	
	sf_complexwrite (yy,nx,out);
    }
    
    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:56,代码来源:Mproj.c


示例4: main

int
main (int argc, char *argv[])
{
    int i;
    int ndims;
    off_t nlarge[SF_MAX_DIM];
    int n[SF_MAX_DIM];
    bool parform, large;
    sf_file in=NULL;

    sf_init(argc,argv);

    in = sf_input("in");

    if (!sf_getbool("large", &large))
        large = false;
    /* if y, file with large dimensions. */

    if (large) {
	ndims = sf_largefiledims(in, nlarge);
    } else {
	ndims = sf_filedims(in, n);
    }

    if (!sf_getbool("parform", &parform))
        parform = true;
    /* If y, print out parameter=value. If n, print out value. */

    if (parform) printf( "ndims=" );

    printf( "%d", ndims );

    if (parform)
        printf( "\nn=" );
    else
        printf( ":" );

    for (i=0; i<ndims; i++) {
	if (large) {
#if defined(__cplusplus) || defined(c_plusplus)
	    printf( "%ld", (long) n[i] );
#else
	    printf( "%lld", (long long) n[i] );
#endif
	} else {
	    printf( "%d", n[i] );
	}
        if (i<ndims-1) printf(",");
    }

    printf( "\n" );


    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:55,代码来源:Mfiledims.c


示例5: vp_coord_init

void vp_coord_init (bool transp1, bool yreverse1)
{
    float crowd, marg;
    bool set;

    if (!sf_getfloat ("screenratio",&screenratio))
	screenratio = VP_SCREEN_RATIO;
    if (!sf_getfloat ("screenht",&screenht))
	screenht = VP_STANDARD_HEIGHT;
    if (!sf_getfloat ("screenwd",&screenwd))
	screenwd = screenht / screenratio;

    if (!sf_getfloat ("crowd",&crowd))   crowd  = 0.75;

    if (!sf_getfloat ("xinch",&inch1)) {
	if (!sf_getfloat ("crowd1",&inch1)) inch1 = crowd;
	inch1 *= screenwd;
    }
    if (!sf_getfloat ("yinch",&inch2)) {
	if (!sf_getfloat ("crowd2",&inch2)) inch2 = crowd;
	inch2 *= screenht;
    }

    set = sf_getfloat ("xll",&xll);
    if (!sf_getfloat ("xur",&xur)) {
	if (set) {
	    xur = xll + inch1;
	} else {
	    marg =  screenwd - inch1;
	    xll = marg * 2./3.;
	    xur = screenwd - marg * 1./3.;
	}
    } else if (!set) {
	xll = xur - inch1;
    }
	
    set = sf_getfloat ("yll",&yll);
    if (!sf_getfloat ("yur",&yur)) {
	if (set) {
	    yur = yll + inch2;
	} else {
	    marg =  screenht - inch1;
	    yll = marg * 1./2.;
	    yur = screenht - marg * 1./2.;
	}
    } else if (!set) {
	yll = yur - inch2;
    }

    if (!sf_getbool ("transp",&transp)) transp = transp1;
    if (!sf_getbool ("xreverse",&xreverse)) xreverse = false;
    if (!sf_getbool ("yreverse",&yreverse)) yreverse = yreverse1;
    if (!sf_getbool ("labelrot",&labelrot)) labelrot = false;
}
开发者ID:1014511134,项目名称:src,代码行数:54,代码来源:gplot.c


示例6: main

int
main (int argc, char *argv[])
{
  const bool su = true;
  bool verb, xdr;
  char *filename, *trace;
  int format=0, ns, ntr, itrace[SF_NKEYS];
  off_t pos, nsegy;
  float dt;
  FILE *file;
  extern int fseeko (FILE * stream, off_t offset, int whence);

/**** Start common code with segy2rsf (16 lines) ****/
  sf_init (argc, argv);

  if (!sf_getbool ("verb", &verb))
    verb = false;
  /* Verbosity flag */

  if (!sf_getbool ("endian", &xdr))
    xdr = true;
  /* Whether to automatically estimate endianness or not */
  if (xdr)
    endian ();

  if (NULL == (filename = sf_getstring ("tape")))	/* input data */
    sf_error ("Need to specify tape=");

  if (NULL == (file = fopen (filename, "rb")))
    sf_error ("Cannot open \"%s\" for reading:", filename);

  pos = readfilesize (file);
/**** End common code with segy2rsf ****/

  /* Figure out ns and ntr */

  trace = sf_charalloc (SF_HDRBYTES);
  if (SF_HDRBYTES != fread (trace, 1, SF_HDRBYTES, file))
    sf_error ("Error reading first trace header");
  fseeko (file, 0, SEEK_SET);

  segy2head (trace, itrace, SF_NKEYS);
  ns = itrace[segykey ("ns")];
  dt = itrace[segykey ("dt")] / 1000000.;
  free (trace);

  nsegy = SF_HDRBYTES + ns * 4;
  ntr = pos / nsegy;

  su_or_segy_to_rsf (verb, su, ntr, format, ns, itrace, nsegy, file, dt);

  exit (0);
}
开发者ID:1014511134,项目名称:src,代码行数:53,代码来源:Msu2rsf.c


示例7: main

int main(int argc, char* argv[])
{
    int nx, nf, ny, i2, n2, lag;
    bool each, trans;
    float *xx, *yy, *ff;
    sf_file in, out, filt;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");
    filt = sf_input("filt");

    if (SF_FLOAT != sf_gettype(in) ||
	SF_FLOAT != sf_gettype(filt)) sf_error("Need float input");
    if (!sf_histint(in,"n1",&nx)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    if (!sf_histint(filt,"n1",&nf)) sf_error("No n1= in filtin");

    xx = sf_floatalloc(nx);
    ff = sf_floatalloc(nf);

    if (!sf_getbool("trans",&trans)) trans=false;
    /* if y, transient convolution; if n, internal */
    if (!sf_getbool("each",&each)) each=false;
    /* if y, new filter for each trace */
    if (!sf_getint("lag",&lag)) lag=1;
    /* lag for internal convolution */

    ny = trans? (nx+nf-1)*(nx+nf-1): nx;
    yy = sf_floatalloc(ny);
    if (trans){
        sf_putint(out,"n1",nx+nf-1);
        sf_putint(out,"n2",nx+nf-1);
    }

    if (!each) sf_floatread (ff,nf,filt);

    for (i2=0; i2 < n2; i2++) {
        if (each) sf_floatread (ff,nf,filt);
        sf_floatread (xx,nx,in);
        if (trans) {
	    tcai1_ns_init(nf,ff);
	    tcai1_ns_lop (false, false,nx,ny,xx,yy);
	} else {
	    icai1_init(nf,ff,lag);
	    icai1_lop (false, false,nx,ny,xx,yy);
	}
	sf_floatwrite (yy,ny,out);
    }

    exit(0);
}
开发者ID:fernandovr89,项目名称:fvillanu,代码行数:53,代码来源:Mtnsconv.c


示例8: main

int main(int argc, char* argv[])
{
    int n1, n2, n12, nv, inv;
    bool adj, add;
    float *modl, *data, o1,d1,o2,d2, vel,v0;
    sf_file in, out;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histint(in,"n2",&n2)) sf_error("No n2= in input");
    n12 = n1*n2;

    if (!sf_histfloat(in,"o1",&o1)) o1=0.;
    if (!sf_histfloat(in,"o2",&o2)) o2=0.;

    if (!sf_histfloat(in,"d1",&d1)) sf_error("No d1= in input");
    if (!sf_histfloat(in,"d2",&d2)) sf_error("No d2= in input");

    if (!sf_getfloat("vel",&vel)) vel=0.75;
    /* final velocity */
    if (!sf_getfloat("v0",&v0)) v0=0.;
    /* starting velocity */
    if (!sf_getint("nv",&nv)) nv=n1;
    /* number of steps */

    if (!sf_getbool("adj",&adj)) adj=false;
    /* adjoint flag */
    if (!sf_getbool("add",&add)) add=false;
    /* addition flag */

    if (!sf_getint("inv",&inv)) inv=0;
    /* amplitude type */

    modl = sf_floatalloc(n12);
    data = sf_floatalloc(n12);

    sf_floatread (adj? data: modl,n12,in);

    velcon_init (inv,vel,v0,o1,n1,n2,nv,d1,d2);
    velcon_lop (adj, add, n12, n12, modl, data);

    sf_floatwrite (adj? modl: data,n12,out);

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:48,代码来源:Mvelcon.c


示例9: main

int main(int argc, char* argv[])
{
    int n1, n2, i2;
    bool adj;
    float *pp, *qq;
    sf_file in=NULL, out=NULL;

    sf_init(argc,argv);

    in = sf_input("in");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    pp = sf_floatalloc(n1);
    qq = sf_floatalloc(n1);

    if (!sf_getbool("adj",&adj)) adj=false;
    /* if y, do adjoint integration */

    for (i2=0; i2 < n2; i2++) {
	sf_floatread(pp,n1,in);
	if (adj) {
	    sf_causint_lop (true,false,n1,n1,qq,pp);
	} else {
	    sf_causint_lop (false,false,n1,n1,pp,qq);
	}
	sf_floatwrite(qq,n1,out);
    }


    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:34,代码来源:Mcausint.c


示例10: main

int main(int argc, char* argv[])
{
    int n1,n2,n12;
    bool adj;
    float d1,d2,o1,o2,v, *model=NULL, *dat=NULL;
    sf_file in=NULL, out=NULL;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histfloat(in,"d1",&d1)) sf_error("No d1= in input");
    if (!sf_histfloat(in,"o1",&o1)) o1=0.;

    if (!sf_getbool("adj",&adj)) adj=false;
    /* adjoint flag */

    if (adj) {
	if (!sf_histint(in,"n2",&n2)) sf_error("No n2= in input");
	if (!sf_histfloat(in,"d2",&d2)) sf_error("No d2= in input");
	if (!sf_histfloat(in,"o2",&o2)) sf_error("No o2= in input");

	sf_putint(out,"n2",1);
    } else {
	if (!sf_getint("n2",&n2)) n2=20;
	/* number of offsets (if inv=n) */
	if (!sf_getfloat("d2",&d2)) d2=200.;
	/* offset sampling (if inv=n) */
	if (!sf_getfloat("o2",&o2)) o2=0.;
	/* offset origin (if inv=n) */

	sf_putint(out,"n2",n2);
	sf_putfloat(out,"d2",d2);
	sf_putfloat(out,"o2",o2);
    }
    n12 = n1*n2;

    if (!sf_getfloat ("v",&v)) v=1000.;
    /* velocity */

    dat = sf_floatalloc(n12);
    model =  sf_floatalloc(n1);

    imospray_init (1./v, o2,d2, o1,d1, n1,n2);

    if (adj) {
	sf_floatread(dat,n12,in);
	imospray_lop (true,false,n1,n12,model,dat);
	sf_floatwrite(model,n1,out);
    } else {	
	sf_floatread(model,n1,in);
	imospray_lop (false,false,n1,n12,model,dat);
	sf_floatwrite(dat,n12,out);
    }

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:58,代码来源:Mimospray.c


示例11: main

int main(int argc, char* argv[])
{
    bool adj, inv;
    int nn,n1,n2,i1,i2;
    float rho, *pp=NULL;
    sf_file in=NULL, out=NULL;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    if (!sf_getbool("adj",&adj)) adj=false;
    /* If y, apply adjoint */
    if (!sf_getbool("inv",&inv)) inv=false;
    /* If y, do differentiation instead of integration */
    if (!sf_getfloat("rho",&rho)) rho = 1.-1./n1;
    /* Leaky integration constant */

    if (inv) {
	sf_warning("%s half-order differentiation",adj? "anticausal":"causal");
    } else {
	sf_warning("%s half-order integration",adj? "anticausal":"causal");
    }

    nn = 2*kiss_fft_next_fast_size((n1+1)/2);
    pp = sf_floatalloc(nn);

    sf_halfint_init (inv, nn, rho);

    for (i2=0; i2 < n2; i2++) {
	sf_floatread (pp,n1,in);
	for (i1=n1; i1 < nn; i1++) {
	    pp[i1]=0.;
	}
	sf_halfint (adj, pp);
	sf_floatwrite (pp,n1,out);
    }

    exit(0);
}
开发者ID:housian0724,项目名称:src,代码行数:43,代码来源:Mhalfint.c


示例12: main

int main(int argc, char* argv[])
{
    int n1, n2, i2;
    float *pp, *qq;
    bool square, adj;
    sf_file in, out;

    sf_init(argc,argv);

    in = sf_input("in");
    out = sf_output("out");

    if (SF_FLOAT != sf_gettype(in)) sf_error("Need float input");
    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    if (!sf_getbool("square",&square)) square=false;
    /* if y, use gradient squared */

    if (!sf_getbool("adj",&adj)) adj=false;
    /* adjoint flag */

    pp = sf_floatalloc(n1);
    qq = sf_floatalloc(n1);

    for (i2=0; i2 < n2; i2++) {
	sf_floatread(pp,n1,in);
	if (square) {
	    sf_grad2 (n1,pp,qq);
	} else if (adj) {
	    sf_igrad1_lop (true,false,n1,n1,qq,pp);
	} else {
	    sf_igrad1_lop (false,false,n1,n1,pp,qq);
	}
	sf_floatwrite(qq,n1,out);
    }

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:39,代码来源:Migrad.c


示例13: main

int main(int argc, char* argv[])
{
    bool verb;
    int i, dim, n[SF_MAX_DIM], nd, rect[SF_MAX_DIM], niter;
    float *noi, *sig, *rat, eps;
    char key[6];
    sf_file fnoi, fsig, flow;

    sf_init(argc,argv);
    fnoi = sf_input("in");
    fsig = sf_input("sig"); /* input signal */

    if (SF_FLOAT != sf_gettype(fnoi) ||
	SF_FLOAT != sf_gettype(fsig)) sf_error("Need float input");

    flow = sf_output("out");

    dim = sf_filedims (fnoi,n);
    nd = 1;
    for (i=0; i < dim; i++) {
	snprintf(key,6,"rect%d",i+1);
	if (!sf_getint(key,rect+i)) rect[i]=1;
	/*( rect#=(1,1,...) smoothing radius on #-th axis )*/ 
	nd *= n[i];
    }

    noi = sf_floatalloc(nd);
    sig = sf_floatalloc(nd);
    rat = sf_floatalloc(nd);    

    if (!sf_getint("niter",&niter)) niter=100;
    /* number of iterations */

    if (!sf_getbool("verb",&verb)) verb=true;
    /* verbosity */

    if (!sf_getfloat("eps",&eps)) eps=0.0f;
    /* regularization */

    sf_divn_init(dim, nd, n, rect, niter, verb);

    sf_floatread(noi,nd,fnoi);
    sf_floatread(sig,nd,fsig);

    sf_divne (noi, sig, rat, eps);

    sf_floatwrite(rat,nd,flow);

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:50,代码来源:Mlow.c


示例14: main

int main(int argc, char* argv[])
{
    bool verb;
    int j, k, n, n2, i3, n3, iter, niter;
    sf_complex **a=NULL, *e=NULL;
    float s2;
    sf_file mat=NULL, val=NULL;

    sf_init(argc,argv);
    mat = sf_input("in");
    val = sf_output("out");

    if (SF_COMPLEX != sf_gettype(mat)) sf_error("Need complex input");
    if (!sf_histint(mat,"n1",&n)) sf_error("No n1= in input");
    if (!sf_histint(mat,"n2",&n2) || n2 != n) sf_error("Need n1=n2 in input");
    n3 = sf_leftsize(mat,2);

    sf_putint(val,"n2",1);

    if (!sf_getint("niter",&niter)) niter=10;
    if (!sf_getbool("verb",&verb)) verb=false;

    a = sf_complexalloc2(n,n);
    e = sf_complexalloc(n);
    jacobi2_init(n,verb);

    for (i3=0; i3 < n3; i3++) {
	sf_complexread(a[0],n*n,mat);
	
	for (iter=0; iter < niter; iter++) {
	    s2 = 0.;
	    for (j=0; j < n; j++) {
		for (k=0; k < n; k++) {
		    s2 += jacobi2(a,n,j,k);
		}
	    }
	    sf_warning("iter=%d s2=%g",iter+1,s2);
	}

	for (j=0; j < n; j++) {
	    e[j]=a[j][j];
	}
	
	sf_complexwrite(e,n, val);
    }

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:48,代码来源:Mjacobi2.c


示例15: main

int main (int argc, char* argv[]) 
{
    bool der;
    int i1, n1, i2, n2, irep, nrep;
    float *data, *data2, rect;
    sf_file in, out;

    sf_init (argc, argv);
    in = sf_input ("in");
    out = sf_output ("out");

    if (SF_FLOAT != sf_gettype(in)) sf_error("Need float input");
    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    if (!sf_getbool("der",&der)) der=false;
    /* compute derivative */

    if (!sf_getfloat("rect",&rect)) rect=1;
    /* smoothing radius */ 
    recgauss_init (n1,der,rect);

    data = sf_floatalloc (n1);
    data2 = der? sf_floatalloc (n1): NULL;

    if (!sf_getint("repeat",&nrep)) nrep=1;
    /* repeat filtering several times */

    for (i2=0; i2 < n2; i2++) {
	if (der) {
	    sf_floatread(data2,n1,in);
	    data[0] = data2[1]-data2[0];
	    for (i1=1; i1 < n1-1; i1++) {
		data[i1] = 0.5*(data2[i1+1]-data2[i1-1]);
	    }
	    data[n1-1] = data2[n1-1]-data2[n1-2];
	} else {
	    sf_floatread(data,n1,in);
	}

	for (irep=0; irep < nrep; irep++) {
	    recgauss (data);
	}
	sf_floatwrite(data,n1,out);
    }    

    exit (0);
}
开发者ID:1014511134,项目名称:src,代码行数:48,代码来源:Mgaussmooth.c


示例16: main

int main (int argc, char* argv[])
{

    int i,n1,n2,n22,n;
    float *A, *x, *d;
    bool verb;
    sf_file in, rhs, out;

    sf_init (argc,argv);
    in = sf_input("in");
    rhs= sf_input("rhs");
    out = sf_output("out");
    if (SF_FLOAT != sf_gettype(in)) sf_error("Need float");

    if(!sf_histint(in,"n1",&n1)) sf_error("No n1 in input matrix!");
    if(!sf_histint(in,"n2",&n2)) sf_error("No n2 in input matrix!");
    if(!sf_histint(rhs,"n2",&n22))sf_error("No n2 in input vector!");
    if(!sf_getbool("verb",&verb)) verb=false;
    if((n1!=n2) || (n1!=n22)) sf_error("Dimension mistake!");
    n=n1;

    x = sf_floatalloc(n);
    A=sf_floatalloc(n*n);
    d=sf_floatalloc(n);

    sf_floatread(A,n*n,in);
    sf_floatread(d,n,rhs);

    trid_init(n, A);
    trid_solve(d, x);
    
    if(verb)
    {
	for(i=0;i<n;i++)
	sf_warning("x[%d]=%f",i+1,x[i]);
    }
    
   sf_putint(out,"n2",n);
   sf_putint(out,"n1",1);
   sf_floatwrite(x,n,out);

   trid_close();
   free(A);
   free(d);
   free(x);
   exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:47,代码来源:Mtrisolver.c


示例17: main

int main(int argc, char* argv[])
{
    bool single;
    int n1, i2, n2, nf, nc;
    sf_complex *trace, *a;
    sf_file in, out;

    sf_init(argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (SF_COMPLEX != sf_gettype(in)) sf_error("Need complex input");
    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");

    if (!sf_getbool("single",&single)) single=true;
    /* single channel or multichannel */

    if (single) {
	nc = 1;
	n2 = sf_leftsize(in,1);
    } else {
	if (!sf_histint(in,"n2",&nc)) nc=1;
	n2 = sf_leftsize(in,2);
	sf_putint(out,"n2",1);
    }

    if (!sf_getint("nf",&nf)) sf_error("Need nf=");
    /* filter length */
    sf_putint(out,"n1",nf);

    cburg_init(n1,nc,nf);

    trace = sf_complexalloc(n1*nc);
    a = sf_complexalloc(nf);

    for (i2=0; i2 < n2; i2++) {
	sf_complexread(trace,n1*nc,in);

	cburg_apply(trace,a);

	sf_complexwrite(a,nf,out);
    }

    exit(0);
}
开发者ID:1014511134,项目名称:src,代码行数:45,代码来源:Mcpef.c


示例18: vp_title_init

void vp_title_init(sf_file file)
{
    char *where;

    if (NULL != (where = sf_getstring("wheretitle"))) {
	verttitle = (*where == 'l' || *where == 'r');
	wheretitle = (*where == 'l' || *where == 't');
    } else {
	verttitle = false;
	wheretitle = true;
    }
    if (!sf_getbool ("wanttitle",&wanttitle)) wanttitle=true;
    if (!sf_getint ("titlefat",&titlefat)) titlefat=0;
    if (!sf_getfloat ("titlesz",&titlesz)) titlesz=10.;
    if (NULL == (title = sf_getstring("title")) &&
	NULL == (title = sf_histstring(file,"title")) &&
	NULL == (title = sf_histstring(file,"in"))) 
	title = blank;
}
开发者ID:1014511134,项目名称:src,代码行数:19,代码来源:gplot.c


示例19: main

int main (int argc, char* argv[])
{
    bool scale;
    int n1,n2, i1,i2, n;
    float d1, *dat, *der;
    sf_file in=NULL, out=NULL;

    sf_init (argc,argv);
    in = sf_input("in");
    out = sf_output("out");

    if (SF_FLOAT != sf_gettype(in)) sf_error("Need float input");
    if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
    n2 = sf_leftsize(in,1);

    dat = sf_floatalloc(n1);
    der = sf_floatalloc(n1);

    if (!sf_getint("order",&n)) n=6;
    /* filter order */

    if (!sf_getbool("scale",&scale) || 
	!sf_histfloat(in,"d1",&d1)) scale=false;
    /*(scale=n if scale by 1/dx )*/

    sf_deriv_init(n1, n, 0.);

    for (i2=0; i2 < n2; i2++) {
	sf_floatread(dat,n1,in);
	sf_deriv(dat,der);

	if (scale) {
	    for (i1=0; i1 < n1; i1++) {
		der[i1] /= d1;
	    }
	}

	sf_floatwrite(der,n1,out);
    }


    exit(0);
}
开发者ID:housian0724,项目名称:src,代码行数:43,代码来源:Mderiv.c


示例20: main

int main(int argc, char* argv[])
{
    bool verb;

    sf_file Fu,Fw; /* I/O files */
    sf_axis a1,a2,a3; /* cube axes */

    float ***uu=NULL, ***ww=NULL;
    int *ii,ik;

    int nh1,nh2,nh3;
    int nb1,nb2,nb3;

    int ih1,ih2,ih3;
    int ib1,ib2,ib3;
    int  n3;
    int  i3;
    int  j1, j2, j3;
    int  k1, k2, k3;

    int ompchunk;

    int lo1,hi1;
    int lo2,hi2;
    int lo3,hi3;

    /*------------------------------------------------------------*/
    /* init RSF */
    sf_init(argc,argv);

    if(! sf_getint("ompchunk",&ompchunk)) ompchunk=1;  /* OpenMP data chunk size */
    if(! sf_getbool("verb",&verb)) verb=false;         /* verbosity flag */

    Fu = sf_input ("in" ); /*  input field */
    Fw = sf_output("out"); /* wigner distribution */

    /* read axes */
    a1=sf_iaxa(Fu,1); sf_setlabel(a1,"a1"); if(verb) sf_raxa(a1);
    a2=sf_iaxa(Fu,2); sf_setlabel(a2,"a2"); if(verb) sf_raxa(a2);
    a3=sf_iaxa(Fu,3); sf_setlabel(a3,"a3"); if(verb) sf_raxa(a3);
    n3 = sf_n(a3);

    if(! sf_getint("nh1",&nh1)) nh1=0;
    if(! sf_getint("nh2",&nh2)) nh2=0;
    if(! sf_getint("nh3",&nh3)) nh3=0;
    if(n3<=1) nh3=0;
    if(verb) sf_warning("nh1=%d nh2=%d nh3=%d",2*nh1+1,2*nh2+1,2*nh3+1);

    nb1 = sf_n(a1);
    nb2 = sf_n(a2);
    nb3=2*nh3+1;

    uu=sf_floatalloc3(nb1,nb2,nb3);
    ww=sf_floatalloc3(nb1,nb2,nb3); 

    ii = sf_intalloc(nb3);
    for(ib3=0;ib3<nb3;ib3++) {
	ii[ib3]=ib3;
    }

    /*------------------------------------------------------------*/
    /* low end on axis 3 */
    /*------------------------------------------------------------*/
    for(         ib3=0; ib3<nb3; ib3++) {
	for(     ib2=0; ib2<nb2; ib2++) {
	    for( ib1=0; ib1<nb1; ib1++) {
		ww[ib3][ib2][ib1] = 0.;
	    }
	}
    }

    sf_floatread(uu[0][0],nb1*nb2*nb3,Fu);

    for(        ih3=-nh3; ih3<nh3+1; ih3++) { lo3=SF_ABS(ih3); hi3=nb3-lo3;
	for(    ih2=-nh2; ih2<nh2+1; ih2++) { lo2=SF_ABS(ih2); hi2=nb2-lo2;
	    for(ih1=-nh1; ih1<nh1+1; ih1++) { lo1=SF_ABS(ih1); hi1=nb1-lo1;
		
		for(        ib3=lo3; ib3<nh3+1;ib3++) { j3=ii[ib3-ih3]; k3=ii[ib3+ih3];
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,ompchunk) \
    private(ib1,ib2,j2,j1,k2,k1) \
    shared(ib3,j3,k3,ih2,ih1,lo2,hi2,lo1,hi1,uu,ww)
#endif
		    for(    ib2=lo2; ib2<hi2;  ib2++) { j2=ib2-ih2; k2=ib2+ih2;
			for(ib1=lo1; ib1<hi1;  ib1++) { j1=ib1-ih1; k1=ib1+ih1;
			    
			    ww[ib3][ib2][ib1] += uu[j3][j2][j1] 
				*                uu[k3][k2][k1];
			} /* nb1  */
		    }     /* nb2  */
		}         /* nb3  */

	    } /* nh1 */
	}     /* nh2 */
    }         /* nh3 */
    
    for(ih3=0;ih3<nh3+1;ih3++) {
	sf_floatwrite(ww[ih3][0],nb1*nb2,Fw);
    }

//.........这里部分代码省略.........
开发者ID:1014511134,项目名称:src,代码行数:101,代码来源:Mwdf.c



注:本文中的sf_getbool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sf_getfloat函数代码示例发布时间:2022-05-30
下一篇:
C++ sf_get_time函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap