本文整理汇总了C++中sf_floatalloc2函数的典型用法代码示例。如果您正苦于以下问题:C++ sf_floatalloc2函数的具体用法?C++ sf_floatalloc2怎么用?C++ sf_floatalloc2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sf_floatalloc2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: upgrad_init
upgrad upgrad_init(int mdim /* number of dimensions */,
const int *mm /* [dim] data size */,
const float *d /* [dim] data sampling */)
/*< initialize >*/
{
upgrad upg;
int i;
if (mdim > 3) sf_error("%s: dim=%d > 3",__FILE__,mdim);
ndim = mdim;
nn = mm;
nt = 1;
for (i=0; i < ndim; i++) {
ss[i] = nt;
nt *= nn[i];
dd[i] = 1.0/(d[i]*d[i]);
}
upg = (upgrad) sf_alloc(1,sizeof(*upg));
upg->update = sf_ucharalloc2(2,nt);
upg->wt = sf_floatalloc2(ndim+1,nt);
upg->wx = sf_floatalloc2(ndim+1,nt);
upg->order = sf_intalloc(nt);
return upg;
}
示例2: rgradient_init
void rgradient_init(char* type, int horder, int m1, int m2)
/*< initialize >*/
{
float **p;
int i;
order = horder;
nf = 2*order+1;
c = sf_floatalloc2(nf, 2);
p = lphpoly(order, order, type);
for(i=0; i<2*nf; i++) c[0][i] = p[0][i];
free(p[0]);
free(p);
mode = type[0];
n1 = m1;
n2 = m2;
b1 = sf_floatalloc2(n1, n2);
b2 = sf_floatalloc2(n1, n2);
g = sf_floatalloc3(n1*3, n2, nf);
b = g[0];
memset(g[0][0], 0, n1*n2*nf*sizeof(float));
#ifdef _OPENMP
omp_init();
#endif
}
示例3: main
int main(int argc, char* argv[])
{
int j, k, n, n2, i3, n3, iter, niter;
float **a, *e, **v, s2;
sf_file mat, val, eig;
sf_init(argc,argv);
mat = sf_input("in");
val = sf_output("out");
if (SF_FLOAT != sf_gettype(mat)) sf_error("Need float 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;
a = sf_floatalloc2(n,n);
e = sf_floatalloc(n);
if (NULL != sf_getstring("eig")) {
eig = sf_output("eig"); /* eigenvectors */
v = sf_floatalloc2(n,n);
for (j=0; j < n; j++) {
for (k=0; k < n; k++) {
v[j][k] = (j==k)? 1.0:0.0;
}
}
} else {
eig = NULL;
v = NULL;
}
jacobi_init(n);
for (i3=0; i3 < n3; i3++) {
sf_floatread(a[0],n*n,mat);
for (iter=0; iter < niter; iter++) {
s2 = 0.;
for (j=0; j < n-1; j++) {
for (k=j+1; k < n; k++) {
s2 += jacobi(a,j,k,v);
}
}
sf_warning("iter=%d s2=%g",iter+1,s2);
}
for (j=0; j < n; j++) {
e[j]=a[j][j];
}
sf_floatwrite(e,n, val);
if (NULL != v) sf_floatwrite(v[0],n*n, eig);
}
exit(0);
}
示例4: main
int main(int argc, char* argv[])
{
int n1, n2, n3, i3;
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");
if (!sf_histint(in,"n2",&n2)) sf_error("No n2= in input");
n3 = sf_leftsize(in,2);
pp = sf_floatalloc2(n1,n2);
qq = sf_floatalloc2(n1,n2);
for (i3=0; i3 < n3; i3++) {
sf_floatread(pp[0],n1*n2,in);
sf_sobel2(n1,n2,pp,qq);
sf_floatwrite(qq[0],n1*n2,out);
}
exit(0);
}
示例5: eno3_init
eno3 eno3_init (int order /* interpolation order */,
int n1, int n2, int n3 /* data dimensions */)
/*< Initialize interpolation object >*/
{
eno3 pnt;
int i2, i3;
pnt = (eno3) sf_alloc(1,sizeof(*pnt));
pnt->order = order;
pnt->n1 = n1;
pnt->n2 = n2;
pnt->n3 = n3;
pnt->ng = 2*order-2;
if (pnt->ng > n2 || pnt->ng > n3)
sf_error("%s: ng=%d is too big",__FILE__,pnt->ng);
pnt->jnt = sf_eno2_init (order, pnt->ng, pnt->ng);
pnt->f = sf_floatalloc2(pnt->ng,pnt->ng);
pnt->f1 = sf_floatalloc2(pnt->ng,pnt->ng);
pnt->ent = (sf_eno**) sf_alloc(n3,sizeof(sf_eno*));
for (i3 = 0; i3 < n3; i3++) {
pnt->ent[i3] = (sf_eno*) sf_alloc(n2,sizeof(sf_eno));
for (i2 = 0; i2 < n2; i2++) {
pnt->ent[i3][i2] = sf_eno_init (order, n1);
}
}
return pnt;
}
示例6: fbdip_init
void fbdip_init(float rad, int m1, int m2,
int *rect, int niter, float dip0, bool vb)
/*< initialize >*/
{
int n, nn[2];
n1 = m1;
n2 = m2;
verb = vb;
u1 = sf_floatalloc2(n1, n2);
u2 = sf_floatalloc2(n1, n2);
u3 = sf_floatalloc2(n1, n2);
u4 = sf_floatalloc2(n1, n2);
u5 = sf_floatalloc2(n1, n2);
p = sf_complexalloc2(n1, n2);
r=rad;
p0 = rad*cexpf(sf_cmplx(0, dip0));
if(rect[0]>0 && rect[1]>0)
{
n = n1*n2;
nn[0] = n1;
nn[1] = n2;
sf_divn_init (2, n, nn, rect, niter, false);
use_divn=true;
}else use_divn=false;
}
示例7: inmo_init
void inmo_init(const float* vel /* velocity */,
const float* off /* offset */,
int nh1 /* number of offsets */,
float h0, float dh, int CDPtype, int ix,
int nt1 /* time samples */, bool slow,
float t0, float dt, float eps, bool half,
int jump1 /* subsampling */)
/*< initialization >*/
{
int it, ih;
float f, h, *coord;
const int nw=4;
nh = nh1;
ns = nt1;
jump = jump1;
nt = (ns-1)*jump+1;
dt = dt/jump;
nmo = (map4*) sf_alloc(nh,sizeof(map4));
stretch = sf_floatalloc(nt);
for (ih=0; ih < nh; ih++) {
nmo[ih] = stretch4_init (nt, t0, dt, nt, eps);
h = off[ih] + (dh/CDPtype)*(ix%CDPtype);
if (half) h *= 2;
h = h*h - h0*h0;
for (it=0; it < nt; it++) {
f = t0 + it*dt;
if (slow) {
f = f*f + h*vel[it]*vel[it];
} else {
f = f*f + h/(vel[it]*vel[it]);
}
if (f < 0.) {
stretch[it]=t0-10.*dt;
} else {
stretch[it] = sqrtf(f);
}
}
stretch4_define (nmo[ih],stretch);
}
coord = sf_floatalloc(nt);
for (it=0; it < nt; it++) {
coord[it] = it;
}
spl = sf_spline_init(nw,ns);
sf_int1_init (coord, 0.0, jump, ns, sf_spline_int, nw, nt, 0.0);
free(coord);
dense2 = sf_floatalloc2(nt,nh);
sparse2 = sf_floatalloc2(ns,nh);
}
示例8: main
int main(int argc, char* argv[])
{
int n1, n2,o1,d1,d2,i1,i2,ix,iz;
float ***dat,**sum;
float sum1;
sf_file in, out; /* Input and output files */
/* Initialize RSF */
sf_init(argc,argv);
/* standard input */
in = sf_input("in");
/* standard output */
out = sf_output("out");
/* parameters from input file*/
if (SF_FLOAT != sf_gettype(in)) sf_error("Need float input");
if (!sf_histint(in,"o1",&o1)) sf_error("No o1= in input");
if (!sf_histint(in,"d1",&d1)) sf_error("No d1= in input");
if (!sf_histint(in,"d2",&d2)) sf_error("No d2= in input");
if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input");
if (!sf_histint(in,"n2",&n2)) sf_error("No n2= in input");
if (!sf_histint(in,"n3",&n3)) sf_error("No n3= in input");
fprintf(stderr,"values: %d %d\n",n1,n2,n3);
sum = sf_floatalloc2(n3,n3);
dat = sf_floatalloc3 (n1,n2,n3);
fprintf(stderr,"values: %d %d\n",n1,n2);
dat = sf_floatalloc2 (n1,n2);
for (ix=0; ix<n2; ++ix) {
for (iz=0; iz<n1; ++iz) {
dat[ix][iz]=0.0;
}
}
sum1=0;
fprintf(stderr,"values1: %f\n",sum1);
sf_floatread(dat[0],n1*n2,in);
//sum1=0;
fprintf(stderr,"values1: %f\n",sum1);
for (i2=o1; i2<n2; ++i2){
for (i1=o1; i1<n1; ++i1){
sum1 += dat[i2][i1];
}
}
fprintf(stderr,"values: %f\n",sum1);
sum[0][0]=sum1;
sf_floatwrite(sum[0],1*1,out);
exit(0);
}
示例9: main
int main(int argc, char* argv[])
{
int i3, n3, ix, nx, iz, nz;
int nx2, nz2, scalex, scalez;
float dx, dz;
float **a, **b;
sf_file in, out;
sf_init(argc, argv);
in=sf_input("in");
out=sf_output("out");
if(!sf_getint("scalex", &scalex)) sf_error("Need scalex=");
if(!sf_getint("scalez", &scalez)) sf_error("Need scalez=");
if(!sf_histint(in, "n1", &nz)) sf_error("No n1= in input");
if(!sf_histfloat(in, "d1", &dz)) sf_error("No d1= in input");
if(!sf_histint(in, "n2", &nx)) sf_error("No n2= in input");
if(!sf_histfloat(in, "d2", &dx)) sf_error("No d2= in input");
nx2=(nx-1)*scalex+1;
nz2=(nz-1)*scalez+1;
n3=sf_leftsize(in, 2);
sf_putint(out, "n1", nz2);
sf_putfloat(out, "d1", dz/scalez);
sf_putint(out, "n2", nx2);
sf_putfloat(out, "d2", dx/scalex);
a=sf_floatalloc2(nz, nx);
b=sf_floatalloc2(nz2, nx2);
for (i3=0; i3<n3; i3++){
sf_floatread(a[0], nz*nx, in);
#pragma omp parallel for private(ix, iz)
for(ix=0; ix<nx2; ix++){
for(iz=0; iz<nz2; iz++){
b[ix][iz]=0.;
}
}
#pragma omp parallel for private(ix, iz)
for(ix=0; ix<nx; ix++){
for(iz=0; iz<nz; iz++){
b[ix*scalex][iz*scalez]=a[ix][iz];
}
}
sf_floatwrite(b[0], nz2*nx2, out);
}
exit(0);
}
示例10: main
int main(int argc, char*argv[])
{
int n1, n2, n3,n4, i2, i3, i4, m2, m3;
sf_file in, hor, out;
float **u, **v, **h, o1, d1;
char *interp;
sinterp intp;
sf_init(argc, argv);
in = sf_input("in");
hor = sf_input("horizon");
out = sf_output("out");
if(!sf_histint(in, "n1", &n1)) sf_error("n1 needed in input");
if(!sf_histfloat(in, "o1", &o1)) o1=0.0;
if(!sf_histfloat(in, "d1", &d1)) d1=1.0;
if(!sf_histint(in, "n2", &n2)) sf_error("n2 needed in input");
if(!sf_histint(in, "n3", &n3)) n3=1;
if(!sf_histint(in, "n4", &n4)) n4=1;
if(!sf_histint(hor, "n1", &m2)) sf_error("n1 needed in horizon file");
if(!sf_histint(hor, "n2", &m3)) m3=1;
if((interp=sf_getstring("interp")) ==NULL ) interp="linear";
/*< interpolation method: nearest, linear >*/
intp = sinterp_c2f(interp);
if(n2!=m2 || n3!= m3) sf_error("horizon file not match");
sf_unshiftdim(in,out,1);
u = sf_floatalloc2(n1, n2);
v = sf_floatalloc2(n2, n3);
h = sf_floatalloc2(n2, n3);
sf_floatread(h[0], n3*n2, hor);
for(i4=0; i4<n4; i4++)
{
for(i3=0; i3<n3; i3++)
{
sf_floatread(u[0], n1*n2, in);
for(i2=0; i2<n2; i2++)
v[i3][i2] = intp(u[i2], (h[i3][i2]-o1)/d1, n1);
}
sf_floatwrite(*v, n2*n3, out);
}
free(*u);
free(u);
free(*v);
free(v);
free(*h);
free(h);
}
示例11: main
int main(int argc,char*argv[])
{
sf_file in, out;
int i1, i2, j2, i3, n1, n2, n3, nf;
float **u1, **u2, sigma, d2;
sf_init(argc,argv);
in = sf_input("in");
out = sf_output("out");
n3 = sf_leftsize(in, 2);
if (!sf_histint(in, "n1", &n1)) sf_error("No n1= in input file");
if (!sf_histint(in, "n2", &n2)) sf_error("No n2= in input file");
if (!sf_getfloat("sigma", &sigma)) sigma=1.0;
/* sigma */
if (!sf_getint("nf", &nf)) nf=100;
/* frequency samples [0, 0.5] */
d2 = SF_PI/(nf-1);
sf_putint(out, "n2", nf);
sf_putfloat(out, "d2", 0.5/(nf-1));
dgauss_init(n1, 1.0/sigma);
u1 = sf_floatalloc2(n1, n2);
u2 = sf_floatalloc2(n1, nf);
for (i3=0; i3<n3; i3++)
{
sf_floatread(u1[0], n1*n2, in);
for(i1=0; i1<n1; i1++)
{
for (j2=0; j2<nf; j2++)
for (i2=0; i2<n2; i2++)
{
u2[j2][i1] = u1[i2][i1] * dgauss_val(i2, d2*j2)
* powf(0.5/SF_PI, i2);
}
}
sf_floatwrite(u2[0], n1*nf, out);
}
free(u1[0]);
free(u2[0]);
free(u1);
free(u2);
dgauss_close();
exit(0);
}
示例12: main
int main(int argc, char* argv[])
{
int nt, nd;
float dist;
float **points, *point;
kd_node tree, near;
sf_file inp, out;
sf_init(argc,argv);
inp = sf_input("in");
out = sf_output("out");
if (SF_FLOAT != sf_gettype(inp)) sf_error("Need float input");
if (!sf_histint(inp,"n1",&nd)) sf_error("No n1= in input");
if (!sf_histint(inp,"n2",&nt)) sf_error("No n2= in input");
sf_putint(out,"n2",1);
points = sf_floatalloc2(nd,nt);
sf_floatread(points[0],nd*nt,inp);
tree = kd_tree(points,nt,nd);
point = sf_floatalloc(nd);
if (!sf_getfloats("point",point,nd)) sf_error("Need point=");
dist = SF_HUGE;
kd_nearest(tree, point, 0, nd, &near, &dist);
sf_floatwrite(kd_coord(near),nd,out);
exit(0);
}
示例13: stretch4_init
map4 stretch4_init (int n1, float o1, float d1 /* regular axis */,
int nd /* data samples */,
float eps /* regularization */)
/*< initialize >*/
{
int i;
map4 str;
str = (map4) sf_alloc (1, sizeof(*str));
str->nt = n1;
str->t0 = o1;
str->dt = d1;
str->nd = nd;
str->eps = eps;
str->x = sf_intalloc (nd);
str->m = sf_boolalloc (nd);
str->w = sf_floatalloc2 (4,nd);
str->diag = sf_floatalloc (str->nt);
for (i = 0; i < 3; i++) {
str->offd[i] = sf_floatalloc (str->nt-1-i);
}
str->slv = sf_banded_init (str->nt,3);
str->tslv = sf_spline4_init(str->nt);
return str;
}
示例14: agrid2_init
agrid2 agrid2_init (int order /* interpolation order */,
int n1, int n2 /* data dimensions */,
int nd, int max)
/*< Initialize interpolation object >*/
{
agrid2 pnt;
int i2;
pnt = (agrid2) sf_alloc(1,sizeof(*pnt));
pnt->order = order;
pnt->n1 = n1;
pnt->n2 = n2;
pnt->nd = nd;
pnt->ng = 2*order-2;
if (pnt->ng > pnt->n2) sf_error("ng is too big in agrid2");
pnt->jnt = sf_eno_init (order, pnt->ng);
pnt->f = sf_floatalloc2(pnt->nd,pnt->ng);
pnt->f1 = sf_floatalloc(pnt->ng);
pnt->ent = (agrid*) sf_alloc(n2,sizeof(agrid));
for (i2 = 0; i2 < n2; i2++) {
pnt->ent[i2] = agrid_init (n1, nd, max);
}
return pnt;
}
示例15: warp3_init
void warp3_init(int n1_in, float o1, float d1,
int n2_in, float o2, float d2,
int n3_in, float o3, float d3 /* output grid */,
int nt, int ny_in, int nx_in /* input grid */,
float eps /* regularization */)
/*< initialize >*/
{
n1 = n1_in;
n2 = n2_in;
n3 = n3_in;
ny = ny_in;
nx = nx_in;
map1 = stretch4_init (n1, o1, d1, nt, eps);
trace1 = sf_floatalloc(n1);
trace2 = sf_floatalloc2(n2,n3);
warp2_init(n2,o2,d2,
n3,o3,d3,
ny,nx,eps);
str2 = sf_floatalloc3(ny,nx,n1);
str3 = sf_floatalloc3(ny,nx,n1);
slice1 = sf_floatalloc3(ny,nx,n1);
}