static void draw_nodes() #endif { GNODE v; debugmessage("draw_nodes",""); if (supress_nodes) return; v = nodelist; while (v) { if (NWIDTH(v)==0) { v = NNEXT(v); continue; } gs_setshrink(G_stretch * NSTRETCH(v), G_shrink * NSHRINK(v) ); gs_setto(NX(v) * G_stretch / G_shrink, NY(v) * G_stretch / G_shrink ); draw_one_node(v); v = NNEXT(v); } v = labellist; while (v) { if (NWIDTH(v)==0) { v = NNEXT(v); continue; } gs_setshrink(G_stretch * NSTRETCH(v), G_shrink * NSHRINK(v) ); gs_setto(NX(v) * G_stretch / G_shrink, NY(v) * G_stretch / G_shrink ); gs_stringbox(v); v = NNEXT(v); } #undef DEBUGDUMMY #ifdef DEBUGDUMMY v = dummylist; while (v) { if ((NWIDTH(v)==0)&&(NHEIGHT(v)==0)) { NWIDTH(v) = NHEIGHT(v) = 9; NBORDERW(v) = 5; NCOLOR(v) = BLACK; gs_setshrink(G_stretch, G_shrink); gs_setto(NX(v) * G_stretch / G_shrink, NY(v) * G_stretch / G_shrink ); draw_one_node(v); NWIDTH(v) = NHEIGHT(v) = 0; NBORDERW(v) = 0; } v = NNEXT(v); } #endif /* Normal dummy nodes need not to be drawn, because they have no size. * Anchor nodes are drawn. */ v = dummylist; while (v) { if (NANCHORNODE(v)) gs_anchornode(v); v = NNEXT(v); } }
static void dview_draw_outlined_box(DView *dv, int rtype, int x, int y, int w, int h, rgb_t bg) { rectangle r; dview_get_rect(dv, rtype, &r); ui_draw_outlined_box(dv->container, NX(dv, x + r.min_x), NY(dv, y + r.min_y), NX(dv, x + r.min_x + w), NY(dv, y + r.min_y + h), bg); }
static void dview_draw_box(DView *dv, int rtype, int x, int y, int w, int h, rgb_t col) { rectangle r; dview_get_rect(dv, rtype, &r); dv->container->add_rect(NX(dv, x + r.min_x), NY(dv, y + r.min_y), NX(dv, x + r.min_x + w), NY(dv, y + r.min_y + h), col, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); }
static void qjoin(qarena_t *arena) { void *p = arena+1; void *end = (char *)arena + arena->size; while (p && p < end) { if (NX(p) < end && ISFREE(p) && ISFREE(NX(p))) { SZ(p) += BSZ(NX(p)); } else { p = NX(p); } } }
static inline void dyn_free_block (void *p, int words) { assert (words >= PTR_INTS); FreeCnt[words]++; if (!((long) p & 7)) { NX(p) = FreeBlocksAligned[words]; FreeBlocksAligned[words] = p; } else { NX(p) = FreeBlocks[words]; FreeBlocks[words] = p; } if (words > PTR_INTS) { MAGIC(p) = DYN_FREE_MAGIC; } }
void DataSet_3D::GridInfo() const { if (gridBin_ == 0) return; Vec3 const& oxyz = gridBin_->GridOrigin(); mprintf("\t\t-=Grid Dims=- %8s %8s %8s\n", "X", "Y", "Z"); mprintf("\t\t Bins: %8zu %8zu %8zu\n", NX(), NY(), NZ()); mprintf("\t\t Origin: %8g %8g %8g\n", oxyz[0], oxyz[1], oxyz[2]); if (gridBin_->IsOrthoGrid()) { GridBin_Ortho const& gb = static_cast<GridBin_Ortho const&>( *gridBin_ ); mprintf("\t\t Spacing: %8g %8g %8g\n", gb.DX(), gb.DY(), gb.DZ()); mprintf("\t\t Center: %8g %8g %8g\n", oxyz[0] + (NX()/2)*gb.DX(), oxyz[1] + (NY()/2)*gb.DY(), oxyz[2] + (NZ()/2)*gb.DZ()); //mprintf("\tGrid max : %8.3f %8.3f %8.3f\n", grid.MX(), grid.MY(), grid.MZ()); } else { Box box(gridBin_->Ucell()); mprintf("\t\tBox: %s ABC={%g %g %g} abg={%g %g %g}\n", box.TypeName(), box[0], box[1], box[2], box[3], box[4], box[5]); } }
/* ================================================================================== Documentacao CalculaPeso ================================================================================== Descrição: Existem dois tipos de mascaras, uma com peso=1 e outras com peso>1 Se a mascara tiver peso maior que 1 esta funcao deve ser chamada Ou o peso deve ser calculado diretamente na funcao de preenchimento da mascara Programador: Andre Duarte Bueno */ float CMascara::CalculaPeso () { peso = 0; for (unsigned int i = 0; i < NX (); i++) { // percorre a mascara for (unsigned int j = 0; j < NY (); j++) { peso += data2D[i][j]; // calcula peso acumulado } } if (peso == 0) { peso = 1; // o peso é utilizado no filtro numa divisao } return peso; // e nao pode assumir o valor 0 }
static void dview_draw_char(DView *dv, int rtype, int x, int y, int h, rgb_t col, UINT16 ch) { rectangle r; dview_get_rect(dv, rtype, &r); dv->container->add_char( NX(dv, x + r.min_x), NY(dv, y + r.min_y), NY(dv, h), debug_font_aspect, //(float) rect_get_height(&dv->bounds) / (float) rect_get_width(&dv->bounds), //render_get_ui_aspect(), col, *debug_font, ch); }
/* ------------------------------------------------------------------------- Função: Go ------------------------------------------------------------------------- @short : Calcula o histograma de níveis de cinza @author : André Duarte Bueno Matrizes @param : Recebe uma matriz 2D @return : Retorna this */ CHistograma * CHistograma::Go (TCMatriz2D< int > *matriz) { // Desaloca(); // nx=pow(2,matriz->BitsPixel()); if (data1D) // Só calcula se os dados foram corretamente alocados { Constante (0); // zera o vetor histograma for (int j = 0; j < matriz->NY (); j++) // Percorre a imagem2D for (int i = 0; i < matriz->NX (); i++) { if (matriz->data2D[i][j] < this->NX ()) // evita acesso a ponto alem dos limites do vetor histograma data1D[matriz->data2D[i][j]]++; // incrementa } float area = matriz->NX () * matriz->NY (); // área total da imagem for (int k = 0; k < NX (); k++) // Percorre o histograma data1D[k] = static_cast < int >(data1D[k] * 100.0 / area); // coloca histograma no intervalo 0-100 } return this; }
void *qalloc(qarena_t *arena, unsigned size) { void *p = arena+1; void *end = (char *)arena + arena->size; void *n = NULL; size = RNDSZ(size); while (p && p < end) { if (!ISFREE(p) || BSZ(p) < size) { p = NX(p); continue; } if (BSZ(p) > size) { n = (char*)p + size; SZ(n) = SZ(p) - size; SZ(p) = size; } ALLOC(p); return UPTR(p); } return NULL; }
void rtkinit(rtk_t *rtk,const prcopt_t *opt) { gtime_t time0= {0}; // ambc_t ambc0={{0}}; ssat_t ssat0; double *x0=rtk->x; double *P0=rtk->P; double *xa=rtk->xa; double *Pa=rtk->Pa; char *errmsg=rtk->errbuf; int i,j,tmp; double pos[3]; rtk->opt=*opt; rtk->nx=NX(opt); rtk->na=NR(opt); //base position #ifdef BASE_POS_TYPE_LLH pos[0]=opt->rb[0]*D2R; pos[1]=opt->rb[1]*D2R; pos[2]=opt->rb[2]; pos2ecef(pos,rtk->rb); #else for (i=0; i<3; i++) rtk->rb[i]=opt->rb[i]; #endif //base velocity for (i=3; i<6; i++) { rtk->rb[i] = 0.0; } //rover position and velocities for (i=0; i<6; i++) rtk->sol.rr[i]=0.0; rtk->sol.dtr[0]=0.0; rtk->sol.time=time0; rtk->tt = 0.0;//time diff for (i=0,tmp=0; i<rtk->nx; i++) { x0[i]=0.0; for (j=0; j<rtk->nx; j++) { P0[tmp++]=0.0; } } for (i=0,tmp=0; i<rtk->na; i++) { xa[i]=0.0; for (j=0; j<rtk->na; j++) { Pa[tmp++]=0.0; } } rtk->nfix=rtk->neb=0; for (i=0; i<MAX_SAT; i++) { // rtk->ambc[i]=ambc0; rtk->ssat[i]=ssat0; } for (i=0; i<MAX_ERRMSG; i++) { errmsg[i]=0; } }
/* phase and code residuals --------------------------------------------------*/ static int res_ppp(int iter, const obsd_t *obs, int n, const double *rs, const double *dts, const double *vare, const int *svh, const nav_t *nav, const double *x, rtk_t *rtk, double *v, double *H, double *R, double *azel) { prcopt_t *opt=&rtk->opt; double r,rr[3],disp[3],pos[3],e[3],meas[2],dtdx[3],dantr[NFREQ]={0}; double dants[NFREQ]={0},var[MAXOBS*2],dtrp=0.0,vart=0.0,varm[2]={0}; int i,j,k,sat,sys,nv=0,nx=rtk->nx,brk,tideopt; trace(3,"res_ppp : n=%d nx=%d\n",n,nx); for (i=0;i<MAXSAT;i++) rtk->ssat[i].vsat[0]=0; for (i=0;i<3;i++) rr[i]=x[i]; /* earth tides correction */ if (opt->tidecorr) { tideopt=opt->tidecorr==1?1:7; /* 1:solid, 2:solid+otl+pole */ tidedisp(gpst2utc(obs[0].time),rr,tideopt,&nav->erp,opt->odisp[0], disp); for (i=0;i<3;i++) rr[i]+=disp[i]; } ecef2pos(rr,pos); for (i=0;i<n&&i<MAXOBS;i++) { sat=obs[i].sat; if (!(sys=satsys(sat,NULL))||!rtk->ssat[sat-1].vs) continue; /* geometric distance/azimuth/elevation angle */ if ((r=geodist(rs+i*6,rr,e))<=0.0|| satazel(pos,e,azel+i*2)<opt->elmin) continue; /* excluded satellite? */ if (satexclude(obs[i].sat,svh[i],opt)) continue; /* tropospheric delay correction */ if (opt->tropopt==TROPOPT_SAAS) { dtrp=tropmodel(obs[i].time,pos,azel+i*2,REL_HUMI); vart=SQR(ERR_SAAS); } else if (opt->tropopt==TROPOPT_SBAS) { dtrp=sbstropcorr(obs[i].time,pos,azel+i*2,&vart); } else if (opt->tropopt==TROPOPT_EST||opt->tropopt==TROPOPT_ESTG) { dtrp=prectrop(obs[i].time,pos,azel+i*2,opt,x+IT(opt),dtdx,&vart); } else if (opt->tropopt==TROPOPT_COR||opt->tropopt==TROPOPT_CORG) { dtrp=prectrop(obs[i].time,pos,azel+i*2,opt,x,dtdx,&vart); } /* satellite antenna model */ if (opt->posopt[0]) { satantpcv(rs+i*6,rr,nav->pcvs+sat-1,dants); } /* receiver antenna model */ antmodel(opt->pcvr,opt->antdel[0],azel+i*2,opt->posopt[1],dantr); /* phase windup correction */ if (opt->posopt[2]) { windupcorr(rtk->sol.time,rs+i*6,rr,&rtk->ssat[sat-1].phw); } /* ionosphere and antenna phase corrected measurements */ if (!corrmeas(obs+i,nav,pos,azel+i*2,&rtk->opt,dantr,dants, rtk->ssat[sat-1].phw,meas,varm,&brk)) { continue; } /* satellite clock and tropospheric delay */ r+=-CLIGHT*dts[i*2]+dtrp; trace(5,"sat=%2d azel=%6.1f %5.1f dtrp=%.3f dantr=%6.3f %6.3f dants=%6.3f %6.3f phw=%6.3f\n", sat,azel[i*2]*R2D,azel[1+i*2]*R2D,dtrp,dantr[0],dantr[1],dants[0], dants[1],rtk->ssat[sat-1].phw); for (j=0;j<2;j++) { /* for phase and code */ if (meas[j]==0.0) continue; for (k=0;k<nx;k++) H[k+nx*nv]=0.0; v[nv]=meas[j]-r; for (k=0;k<3;k++) H[k+nx*nv]=-e[k]; if (sys!=SYS_GLO) { v[nv]-=x[IC(0,opt)]; H[IC(0,opt)+nx*nv]=1.0; } else { v[nv]-=x[IC(1,opt)]; H[IC(1,opt)+nx*nv]=1.0; } if (opt->tropopt>=TROPOPT_EST) { for (k=0;k<(opt->tropopt>=TROPOPT_ESTG?3:1);k++) { H[IT(opt)+k+nx*nv]=dtdx[k]; } } if (j==0) { v[nv]-=x[IB(obs[i].sat,opt)]; H[IB(obs[i].sat,opt)+nx*nv]=1.0; } var[nv]=varerr(obs[i].sat,sys,azel[1+i*2],j,opt)+varm[j]+vare[i]+vart; if (j==0) rtk->ssat[sat-1].resc[0]=v[nv]; else rtk->ssat[sat-1].resp[0]=v[nv]; /* test innovation */ #if 0 if (opt->maxinno>0.0&&fabs(v[nv])>opt->maxinno) { #else if (opt->maxinno>0.0&&fabs(v[nv])>opt->maxinno&&sys!=SYS_GLO) { #endif trace(2,"ppp outlier rejected %s sat=%2d type=%d v=%.3f\n", time_str(obs[i].time,0),sat,j,v[nv]); rtk->ssat[sat-1].rejc[0]++; continue; } if (j==0) rtk->ssat[sat-1].vsat[0]=1; nv++; } } for (i=0;i<nv;i++) for (j=0;j<nv;j++) { R[i+j*nv]=i==j?var[i]:0.0; } trace(5,"x=\n"); tracemat(5,x, 1,nx,8,3); trace(5,"v=\n"); tracemat(5,v, 1,nv,8,3); trace(5,"H=\n"); tracemat(5,H,nx,nv,8,3); trace(5,"R=\n"); tracemat(5,R,nv,nv,8,5); return nv; } /* number of estimated states ------------------------------------------------*/ extern int pppnx(const prcopt_t *opt) { return NX(opt); } /* precise point positioning -------------------------------------------------*/ extern void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) { const prcopt_t *opt=&rtk->opt; double *rs,*dts,*var,*v,*H,*R,*azel,*xp,*Pp; int i,nv,info,svh[MAXOBS],stat=SOLQ_SINGLE; trace(3,"pppos : nx=%d n=%d\n",rtk->nx,n); rs=mat(6,n); dts=mat(2,n); var=mat(1,n); azel=zeros(2,n); for (i=0;i<MAXSAT;i++) rtk->ssat[i].fix[0]=0; /* temporal update of states */ udstate_ppp(rtk,obs,n,nav); trace(4,"x(0)="); tracemat(4,rtk->x,1,NR(opt),13,4); /* satellite positions and clocks */ satposs(obs[0].time,obs,n,nav,rtk->opt.sateph,rs,dts,var,svh); /* exclude measurements of eclipsing satellite */ if (rtk->opt.posopt[3]) { testeclipse(obs,n,nav,rs); } xp=mat(rtk->nx,1); Pp=zeros(rtk->nx,rtk->nx); matcpy(xp,rtk->x,rtk->nx,1); nv=n*rtk->opt.nf*2; v=mat(nv,1); H=mat(rtk->nx,nv); R=mat(nv,nv); for (i=0;i<rtk->opt.niter;i++) { /* phase and code residuals */ if ((nv=res_ppp(i,obs,n,rs,dts,var,svh,nav,xp,rtk,v,H,R,azel))<=0) break; /* measurement update */ matcpy(Pp,rtk->P,rtk->nx,rtk->nx); if ((info=filter(xp,Pp,H,v,R,rtk->nx,nv))) { trace(2,"ppp filter error %s info=%d\n",time_str(rtk->sol.time,0), info); break; } trace(4,"x(%d)=",i+1); tracemat(4,xp,1,NR(opt),13,4); stat=SOLQ_PPP; } if (stat==SOLQ_PPP) { /* postfit residuals */ res_ppp(1,obs,n,rs,dts,var,svh,nav,xp,rtk,v,H,R,azel); /* update state and covariance matrix */ matcpy(rtk->x,xp,rtk->nx,1); matcpy(rtk->P,Pp,rtk->nx,rtk->nx); /* ambiguity resolution in ppp */ if (opt->modear==ARMODE_PPPAR||opt->modear==ARMODE_PPPAR_ILS) { if (pppamb(rtk,obs,n,nav,azel)) stat=SOLQ_FIX; } /* update solution status */ rtk->sol.ns=0; for (i=0;i<n&&i<MAXOBS;i++) { if (!rtk->ssat[obs[i].sat-1].vsat[0]) continue; rtk->ssat[obs[i].sat-1].lock[0]++; rtk->ssat[obs[i].sat-1].outc[0]=0; rtk->ssat[obs[i].sat-1].fix [0]=4; rtk->sol.ns++; } rtk->sol.stat=stat; for (i=0;i<3;i++) { rtk->sol.rr[i]=rtk->x[i]; rtk->sol.qr[i]=(float)rtk->P[i+i*rtk->nx]; } rtk->sol.qr[3]=(float)rtk->P[1]; rtk->sol.qr[4]=(float)rtk->P[2+rtk->nx]; rtk->sol.qr[5]=(float)rtk->P[2]; rtk->sol.dtr[0]=rtk->x[IC(0,opt)]; rtk->sol.dtr[1]=rtk->x[IC(1,opt)]-rtk->x[IC(0,opt)]; for (i=0;i<n&&i<MAXOBS;i++) { rtk->ssat[obs[i].sat-1].snr[0]=MIN(obs[i].SNR[0],obs[i].SNR[1]); } for (i=0;i<MAXSAT;i++) { if (rtk->ssat[i].slip[0]&3) rtk->ssat[i].slipc[0]++; } } free(rs); free(dts); free(var); free(azel); free(xp); free(Pp); free(v); free(H); free(R); }
void *dyn_alloc (long size, int align) { int tmp; char *r = 0; assert (size >= 0 && (unsigned long) size < (unsigned long) dynamic_data_buffer_size); size = (size + 3) & -4; if (dyn_mark_top) { r = dyn_cur + ((align - (long) dyn_cur) & (align - 1)); if (dyn_top <= r || dyn_top < r + size) { if (verbosity > 0) { fprintf (stderr, "unable to allocate %ld bytes\n", size); } return 0; } dyn_cur = r + size; return r; } if (size < PTRSIZE) { size = PTRSIZE; } long t = ((unsigned long) size >> 2); if (t < MAX_RECORD_WORDS && FreeBlocks[t] && align == 4) { r = FreeBlocks[t]; assert (r >= dyn_first && r <= dyn_last - size && !(((long) r) & 3)); if (t > PTR_INTS) { assert (MAGIC(r) == DYN_FREE_MAGIC); MAGIC(r) = 0; } FreeBlocks[t] = NX(r); FreeCnt[t]--; UsedCnt[t]++; NewAllocations[t][1]++; return r; } if (t < MAX_RECORD_WORDS && FreeBlocksAligned[t] && (align == 4 || align == 8)) { r = FreeBlocksAligned[t]; assert (r >= dyn_first && r <= dyn_last - size && !(((long) r) & 7)); if (t > PTR_INTS) { assert (MAGIC(r) == DYN_FREE_MAGIC); MAGIC(r) = 0; } FreeBlocksAligned[t] = NX(r); FreeCnt[t]--; UsedCnt[t]++; NewAllocations[t][1]++; return r; } if (t < MAX_RECORD_WORDS) { tmp = SplitBlocks[t]; if (tmp) { if (tmp > 0) { assert (tmp >= t + PTR_INTS); if (FreeBlocks[tmp] && (PTR_INTS == 1 || align == 4 || tmp >= t + 5)) { r = FreeBlocks[tmp]; } else if (FreeBlocksAligned[tmp]) { r = FreeBlocksAligned[tmp]; } else { tmp = -t - PTR_INTS; } } if (tmp < 0) { tmp = -tmp; int tmp2 = tmp + 5; if (tmp2 > MAX_RECORD_WORDS - 1) { tmp2 = MAX_RECORD_WORDS - 1; } while (++tmp < tmp2) { if (FreeBlocks[tmp] && (PTR_INTS == 1 || align == 4 || tmp >= t + 5)) { r = FreeBlocks[tmp]; break; } else if (FreeBlocksAligned[tmp]) { r = FreeBlocksAligned[tmp]; break; } } if (tmp < MAX_RECORD_WORDS) { SplitBlocks[t] = -tmp; } } } } if (t < MAX_RECORD_WORDS && r && (align == 4 || align == 8)) { char *q = r + size; assert (tmp > t); assert (r >= dyn_first && r <= dyn_last - size && !(((long) r) & 3)); if (t > PTR_INTS) { assert (MAGIC(r) == DYN_FREE_MAGIC); MAGIC(r) = 0; } if (r == FreeBlocks[tmp]) { FreeBlocks[tmp] = NX(r); } else { FreeBlocksAligned[tmp] = NX(r); } FreeCnt[tmp]--; UsedCnt[t]++; NewAllocations[t][2]++; if (align == 4 || !((long) r & 7)) { tmp -= t; dyn_free_block (q, tmp); return r; } else if ((tmp - t) & 1) { tmp -= t; dyn_free_block (r, tmp); return r + tmp*4; } else { int z = 2 * PTR_INTS - 1; dyn_free_block (r, z); r += z*4; q += z*4; tmp -= t + z; assert (tmp >= 0); if (tmp > 0) { dyn_free_block (q, tmp); } return r; } } r = dyn_cur + ((align - (long) dyn_cur) & (align - 1)); if (dyn_top <= r || dyn_top < r + size) { if (verbosity > 0) { fprintf (stderr, "unable to allocate %ld bytes\n", size); } return 0; } if (t < MAX_RECORD_WORDS) { NewAllocations[t][0]++; UsedCnt[t]++; } dyn_cur = r + size; return r; }
int Run(int argc, char ** argv) { int N = 10; int nbIterations = 10; std::string momentumPath, outputPath = "./", deviceName, sourcePath = "./OpenCL.cl"; if (argc < 3) { usage(); return 1; } auto image = ScalarField::Read({ argv[1] }); auto target = ScalarField::Read({ argv[2] }); argc -= 2; argv += 2; Matrix<4, 4> transfo; memset(&transfo[0], 0, 16 * sizeof(float)); transfo[0][0] = transfo[1][1] = transfo[2][2] = transfo[3][3] = 1; std::array<float, 7> weights = {{ 100.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }}, sigmaXs = {{ 3.f, 3.f, 3.f, 3.f, 3.f, 3.f, 3.f }}, sigmaYs = {{ 3.f, 3.f, 3.f, 3.f, 3.f, 3.f, 3.f }}, sigmaZs = {{ 3.f, 3.f, 3.f, 3.f, 3.f, 3.f, 3.f }}; float alpha = 0.001f, maxVeloUpdate = 0.5f; while (argc > 1) { auto arg = std::string { argv[1] }; --argc; ++argv; if (arg == "-subdivisions" && argc > 1) { N = atoi(argv[1]); --argc; ++argv; } else if (arg == "-iterations" && argc > 1) { nbIterations = atoi(argv[1]); --argc; ++argv; } else if (arg == "-InputInitMomentum" && argc > 1) { momentumPath = argv[1]; --argc; ++argv; } else if (arg == "-OutputPath" && argc > 1) { outputPath = argv[1]; --argc; ++argv; } else if (arg == "-Device" && argc > 1) { deviceName = argv[1]; --argc; ++argv; } else if (arg == "-ShowDevices") { for (auto && d : compute::system::devices()) std::cout << d.name() << std::endl; return 0; } else if (arg == "-affineT" && argc > 12) { for (auto i = 1; i <= 12; ++i) transfo[(i - 1) / 4][(i - 1) % 4] = atof(argv[i]); argc -= 12; argv += 12; } else if (arg == "-Gauss" && argc > 1) { sigmaXs[0] = sigmaYs[0] = sigmaZs[0] = atof(argv[1]); --argc; ++argv; } else if (arg == "-M_gauss" && argc > 1) { auto temp = atoi(argv[1]); --argc; ++argv; for (auto i = 1; i <= 7; ++i) { if (temp >= i && argc > 2) { weights[i - 1] = atof(argv[1]); sigmaXs[i - 1] = sigmaYs[i - 1] = sigmaZs[i - 1] = atof(argv[2]); argc -= 2; argv += 2; } } } else if (arg == "-M_Gauss_easier" && argc > 2) { sigmaXs[0] = atof(argv[1]); sigmaXs[6] = atof(argv[2]); argc -= 2; argv += 2; if (sigmaXs[0] < sigmaXs[6]) { std::swap(sigmaXs[0], sigmaXs[6]); } sigmaYs[0] = sigmaZs[0] = sigmaXs[0]; sigmaYs[6] = sigmaZs[6] = sigmaXs[6]; weights[0] = 0.f; auto a = (sigmaYs[6] - sigmaYs[0]) / 6.f; auto b = sigmaYs[0] - a; for (auto i = 2; i <= 6; ++i) sigmaXs[i - 1] = sigmaYs[i - 1] = sigmaZs[i - 1] = i * a + b; } else if (arg == "-alpha" && argc > 1) { alpha = atof(argv[1]); --argc; ++argv; } else if (arg == "-MaxVeloUpdate" && argc > 1) { maxVeloUpdate = atof(argv[1]); --argc; ++argv; } else if (arg == "-KernelSource" && argc > 1) { sourcePath = argv[1]; --argc; ++argv; } else { usage(); return 1; } } ScalarField momentum; if (momentumPath.empty()) { momentum = ScalarField { image.NX(), image.NY(), image.NZ() }; momentum.Fill(0.f); } else momentum = ScalarField::Read({ momentumPath.c_str() }); if (deviceName.empty()) SetDevice(compute::system::default_device()); else SetDevice(compute::system::find_device(deviceName)); std::cout << "OpenCL will use " << GetDevice().name() << std::endl; compute::command_queue queue { GetContext(), GetDevice() }; SetSourcePath(std::move(sourcePath)); GeoShoot gs { std::move(image), std::move(target), std::move(momentum), transfo, N, queue }; gs.Weights = std::move(weights); gs.SigmaXs = std::move(sigmaXs); gs.SigmaYs = std::move(sigmaYs); gs.SigmaZs = std::move(sigmaZs); gs.Alpha = alpha; gs.MaxUpdate = maxVeloUpdate; gs.Run(nbIterations); queue.finish(); gs.Save(outputPath); return 0; }