Exemple #1
0
template <class cCRNode> void  cTplCoxRoyAlgo<cCRNode>::SetStdCostRegul(double aCoeff,double aCste,int aVmin)
{
    for (int anX=X0(); anX<X1() ; anX++)
        for (int anY=Y0(); anY<Y1() ; anY++)
             for (int aZ = ZMin(anX,anY); aZ< ZMax(anX,anY) ; aZ++)
             {
                 cRoyPt    aP1 (anX,anY,aZ);
                 cCRNode & aS1 = NodeOfP(aP1);
                 int  aC1 = aS1.ResidualFlow(mDirZPlus);

                 for (int anEdg=0; anEdg<NbEdges() ; anEdg++)
                 {
                     if (aS1.EdgeIsValide(anEdg) && (!tabCRIsVertical[anEdg]))
                     {
                           cRoyPt aP2(aP1,anEdg);
                           cCRNode & aS2 = NodeOfP(aP2);
                           int aC2 = aS2.ResidualFlow(mDirZPlus);

                           double aCost = aCste + aCoeff*(aC1+aC2)/2.0;
                           if (Cnx8())
                               aCost *= tabCRIsArcV8[anEdg] ? 0.2928 : 0.4142 ;
                           int iCost = int(aCost+0.5);
                           if (iCost<aVmin)
                              iCost = aVmin;
                           aS1.SetResidualFlow(anEdg,iCost);
                     }
                 }
             }
}
Exemple #2
0
void cpp_wrap_Y1(const double* vM_,
				   const double* zeta_,
				   const unsigned int& m,
				   const unsigned int& n,
				   double* Y1_) {
	Y1(vM_,zeta_,m,n,Y1_);
}
Exemple #3
0
dMatrix  clSpline::GetFirstDerivatives(void)
{
  dMatrix dummy;

  if(!initialised)
  {
    Initialise();
  }

  dummy.SetNumberRows(X1.GetNumberRows());
  dummy.SetNumberColumns(3);

  for(int i=1; i<=X1.GetNumberRows(); i++)
  {
    dummy.SetElement(i, 1, fabs(X1(i, 1)) < PRECISION ? 0.0 : X1(i, 1));
    dummy.SetElement(i, 2, fabs(Y1(i, 1)) < PRECISION ? 0.0 : Y1(i, 1));
    dummy.SetElement(i, 3, fabs(Z1(i, 1)) < PRECISION ? 0.0 : Z1(i, 1));
  }

  return(dummy);
}
void up_rk4_abm(VectorXd &F_Eingang, double h, MatrixXd &Y, M_struct &M1, int j) {

	double F;
	double F_grad;
	F = F_Eingang(1);
	F_grad = F_Eingang(2);

	MatrixXd dy1;
	MatrixXd dy2;
	MatrixXd dy3;
	MatrixXd dy4;
	

	MatrixXd Y2;
	MatrixXd Y3;
	MatrixXd Y4;
	
	double F2;
	double F3;
	double F4;
	
	MatrixXd Y1(4 * (n+1), 2);
	Y1 = Y.block(0, 0, 4 * (n + 1), j * 2);
	dy1 = up_ode(Y1, F, M1);

	std::cout << dy1 << std::endl << std::endl << std::endl << Y1;

	Y2 = Y1 + dy1;
	F2 = (F + F_grad * h / 2);
	dy2 = h * up_ode(Y2, F2, M1);

	Y3 = Y1 + dy2 / 2;
	F3 = (F + F_grad * h / 2);
	dy3 = h * up_ode(Y3, F, M1);

	Y4 = Y1 + dy3;
	F2 = (F + F_grad * h);
	dy4 = h * up_ode(Y4, F, M1);

	Y.block(0, j*2, 4 * (n + 1), 2) = Y1 + h / 6 * (dy1 + 2 * dy2 + 3 * dy3 + dy4);



//	std::cout << dy << std::endl << std::endl << std::endl;
}
Exemple #5
0
int main(int argc, char** argv) {

  int l=5;
  TinyVector<double,3> pos(0.1,0.3,-0.45), deltax(0.0001,0.0,0.0), deltay(0.0,0.0001,0.0), deltaz(0.0,0.0,0.0001), tpos, g;
  if(argc>1) l = atoi(argv[1]);
  if(argc>4) {
    pos[0] = atof(argv[2]);
    pos[1] = atof(argv[3]);
    pos[2] = atof(argv[4]);
  }

  SphericalTensor<double,TinyVector<double,3> > Y1(l,true), Y2(l,true), Yp(l,true), Ym(l,true);
  Y1.evaluate(pos);

  std::cout.setf(std::ios::scientific, std::ios::floatfield);
  for(int lm=0; lm<Y1.size(); lm++) {
    std::cout << lm << std::endl;
    std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm] 
      << std::setprecision(12) << Y1.gradYlm[lm] << std::endl;
    //std::cout << std::setw(20) << std::setprecision(12) << Y2.Ylm[lm] 
    //  << std::setprecision(12) << Y2.gradYlm[lm] << std::endl;
  }

//  for(int lm=0; lm<Y1.size(); lm++) {
//    tpos = pos+deltax; Yp.evaluate(tpos);
//    tpos = pos-deltax; Ym.evaluate(tpos);
//    g[0] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002;
//    tpos = pos+deltay; Yp.evaluate(tpos);
//    tpos = pos-deltay; Ym.evaluate(tpos);
//    g[1] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002;
//    tpos = pos+deltaz; Yp.evaluate(tpos);
//    tpos = pos-deltaz; Ym.evaluate(tpos);
//    g[2] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002;
//    std::cout << lm << std::endl;
//    std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm] 
//      << std::setprecision(12) << Y1.gradYlm[lm] - g << std::endl;
//  }
}
Exemple #6
0
void bench_r2d_proj()
{
    Pt2di sz(120,50);

    Im2D_REAL8       MNT(sz.x,sz.y,0.0);
    Im2D_REAL8       X1(sz.x,sz.y,0.0);
    Im2D_REAL8       Y1(sz.x,sz.y,0.0);
    Im2D_REAL8       X2(sz.x,sz.y,0.0);
    Im2D_REAL8       Y2(sz.x,sz.y,0.0);


    ELISE_COPY(MNT.all_pts(),frandr(),MNT.out());

    ELISE_COPY
    (
        MNT.all_pts(),
        proj_cav(MNT.in(),0.5,2.0),
        Virgule(X1.out(),Y1.out())
    );

    ELISE_COPY
    (
        MNT.lmr_all_pts(Pt2di(1,0)),
        proj_cav(MNT.in(),0.5,2.0),
        Virgule(X2.out(),Y2.out())
    );

    REAL dif;

    ELISE_COPY 
    (
         MNT.all_pts(),
         Max(Abs(X1.in()-X2.in()),Abs(Y1.in()-Y2.in())),
         VMax(dif)
    );
    BENCH_ASSERT(dif<epsilon);


    ELISE_COPY
    (
        MNT.all_pts(),
        (2*PI)*phasis_auto_stereogramme(MNT.in(),10.5,2.0),
        X1.out()
    );

    ELISE_COPY
    (
        MNT.lmr_all_pts(Pt2di(1,0)),
        (2*PI)*phasis_auto_stereogramme(MNT.in(),10.5,2.0),
        X2.out()
    );

    ELISE_COPY 
    (
         MNT.all_pts(),
         Max
         (
              Abs(cos(X1.in())-cos(X2.in())),
              Abs(sin(X1.in())-sin(X2.in()))
         ),
         VMax(dif)
    );

    BENCH_ASSERT(dif<epsilon);
}
Exemple #7
0
double C_Rect::diagonale(void) const 
{
  double x = X2() - X1();
  double y = Y2() - Y1();
  return double(sqrt(x*x+y*y));
}
/* readonly attribute nsIDOMSVGAnimatedLength y1; */
NS_IMETHODIMP SVGLinearGradientElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
{
  *aY1 = Y1().get();
  return NS_OK;
}