template <class Type,class TBase> cElN3D_EpipGen<Type,TBase> *  cElN3D_EpipGen<Type,TBase>::TypedClone() const
{
    return new cElN3D_EpipGen<Type,TBase>
               (
                     this->mDir,
                     this->mParams,
                     Fonc_Num(0),
                     Fonc_Num(El_CTypeTraits<Type>::TronqueR(-1e5)),
                     mProfIsZ,
                     this->mEmptyData,
                     false
                     // const_cast<cElN3D_EpipGen<Type,TBase> *>(this)->mImDef.in(),
                     // const_cast<cElN3D_EpipGen<Type,TBase> *>(this)->mIm.in()
               );
}
示例#2
0
int main(int,char **)
{
    Pt2di sz(10,10);
    Im2D_U_INT2 Ifl(sz.x,sz.y,255);


cout << "bench_vecto AAAA\n";

    // cout << Ifl.ptr() << "\n";

    INT aBid;
   ELISE_COPY
   (
       rectangle(Pt2di(0,0),sz),
      // Ifl.all_pts(),
      TOTO  
      (
         Fonc_Num(11), 
         BugAV (Ifl)
      ),
      sigma(aBid)
   );
cout << "bench_vecto BBBBB\n";
exit(-1);



   return 0;
}
示例#3
0
cHomogFormelle::cComp::cComp
(
     cElComposHomographie & aComp,
     cSetEqFormelles &         aSet,
     bool                   IsDenom
)   :
    mX        (aSet.Alloc().NewF(&aComp.CoeffX())),
    mY        (aSet.Alloc().NewF(&aComp.CoeffY())),
    m1        (IsDenom ?
                    Fonc_Num(1) :
                    aSet.Alloc().NewF(&aComp.Coeff1())
              )
{
}
cEqDirecteDistorsion:: cEqDirecteDistorsion
(  
     cParamIntrinsequeFormel & aPIF,
     eTypeEqDisDirecre         Usage,
     bool                Code2Gen
)  :
   mUsage     (Usage),
   mSet       (*aPIF.Set()),
   mPIF       (aPIF),
   mP1        ("PIm1"),
   mP2        ("PIm2"),
   mResidu    (P1_EDD(mPIF,mP1.PtF(),Usage) - mP2.PtF()),
   mNameType  (    "cEqDirectDist" 
                 +  mPIF.NameType() 
		 +  (Usage2Str(Usage))
		 +"_CodGen"
              )
{
     mPIF.IncInterv().SetName("Calib");
     mLInterv.AddInterv(mPIF.IncInterv());

     mFoncEqResidu = cElCompiledFonc::AllocFromName(mNameType);

    if (Code2Gen)
    {
        GenCode();
        return;
    }


    if (mFoncEqResidu==0)
    {
       std::cout << "Name = " << mNameType << "\n";
       ELISE_ASSERT(false,"Can Get Code Comp for cEqCalibCroisee");      
       mFoncEqResidu = cElCompiledFonc::DynamicAlloc(mLInterv,Fonc_Num(0));
    }

    mFoncEqResidu->SetMappingCur(mLInterv,&mSet);


    mP1.InitAdr(*mFoncEqResidu);
    mP2.InitAdr(*mFoncEqResidu);

    aPIF.InitStateOfFoncteur(mFoncEqResidu,0);
    mSet.AddFonct(mFoncEqResidu);
}
示例#5
0
void cBenchLeastSquare::TestFoncNVar()
{
    cFormQuadCreuse aFQuad(mNbVar,false);
    aFQuad.SetEpsB(1e-10);
    cOptimSommeFormelle anOSF(mNbVar);
    for (INT kEq=0; kEq<mNbEq ; kEq++)
    {
	Fonc_Num f = Fonc_Num(0);
        for (INT kV=0; kV<mNbVar ; kV++)
        {
	    f = f+mSys.CoefLin(kV,kEq)*kth_coord(kV);
        }
	f = f-mSys.CoefCste(kEq);
	f = Square(f) *  mSys.Pds(kEq);
	anOSF.Add(f,NRrandom3()<0.5);
	aFQuad.AddDiff(f);
    }
    
    // Verif de gradient + fonc sur aFQuad
    for (INT aNb=0 ; aNb<10 ; aNb++)
    {
       Im1D_REAL8 aPt(mNbVar);
       ELISE_COPY(aPt.all_pts(),frandr(),aPt.out());

       REAL aVSom = anOSF.ValFNV(aPt.data());
       REAL aVQ = aFQuad.ValFNV(aPt.data());
       REAL aVSys = mSys.L2SomResiduPond(aPt); 

       REAL aDif =   DiffRel(aVQ,aVSys,epsilon);
       BENCH_ASSERT(aDif<epsilon);


       aDif =   DiffRel(aVSom,aVSys,epsilon);
       BENCH_ASSERT(aDif<epsilon);

       Im1D_REAL8 aGradQ(mNbVar,0.0);
       Im1D_REAL8 aGradSys(mNbVar,0.0);
       Im1D_REAL8 aGradSom(mNbVar,0.0);

        aFQuad.GradFNV(aGradQ.data(),aPt.data());
        GradFNV(aGradSys.data(),aPt.data());
        anOSF.GradFNV(aGradSom.data(),aPt.data());

        for (INT kV=0; kV<mNbVar ; kV++)
	{
	    REAL aGQ = aGradQ.data()[kV];
	    REAL aGSys = aGradSys.data()[kV];
	    REAL aGSom = aGradSom.data()[kV];

            aDif =   DiffRel(aGQ,aGSys,epsilon);
            BENCH_ASSERT(aDif<epsilon);

            aDif =   DiffRel(aGSom,aGSys,epsilon);
            BENCH_ASSERT(aDif<epsilon);
	}
    }

    // Verif de la formule du gradient
	{
    for (INT aNb=0 ; aNb<10 ; aNb++)
    {
       Im1D_REAL8 aPt(mNbVar,0.0);
       Im1D_REAL8 aGrad(mNbVar,0.0);
       GradFNV(aGrad.data(),aPt.data());

       Im1D_REAL8 aDep(mNbVar,0.0);
       ELISE_COPY(aDep.all_pts(),(frandr()-0.5) * 0.0001,aDep.out());

       REAL aScal;
       ELISE_COPY(aDep.all_pts(),aDep.in()*aGrad.in(),sigma(aScal));

       REAL f1 = mSys.L2SomResiduPond(aDep);
       ELISE_COPY(aDep.all_pts(),-aDep.in(),aDep.out());
       REAL f2 =  mSys.L2SomResiduPond(aDep); 

       REAL aDif = DiffRel(f1,f2,epsilon);
       BENCH_ASSERT(aDif<BIG_epsilon);

    }
	}
    Im1D_REAL8 aPt(mNbVar,0.0);
    powel(aPt.data(),1e-8,200);

    REAL aRes1 = mSys.L2SomResiduPond(mSol);
    REAL aRes2 = mSys.L2SomResiduPond(aPt);
    REAL aDif = DiffRel(aRes1,aRes2,epsilon);
    BENCH_ASSERT(aDif<epsilon);


    ELISE_COPY(aPt.all_pts(),frandr(),aPt.out());
    GradConj(aPt.data(),1e-8,200);
    REAL aRes3 = mSys.L2SomResiduPond(aPt);
    aDif =   DiffRel(aRes1,aRes3,epsilon);
    BENCH_ASSERT(aDif<epsilon);

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




    anOSF. GradConjMin(aPt.data(),1e-8,200);
    REAL aRes4 = mSys.L2SomResiduPond(aPt); 
    aDif =   DiffRel(aRes1,aRes4,epsilon);
    BENCH_ASSERT(aDif<epsilon);
}
示例#6
0
Fonc_Num ElStdTypeScal<Fonc_Num>::RtoT(double aVal)
{
      return Fonc_Num(aVal);
}
示例#7
0
Fonc_Num TCompl<Fonc_Num>::FromC(double aV)
{
  return Fonc_Num(aV);
}
cParamIntrinsequeFormel::cParamIntrinsequeFormel
(
    bool              isDC2M,
    CamStenope  *     aCamInit,
    cSetEqFormelles & aSet,
    bool ParamVar
) :
   cElemEqFormelle (aSet,false),
   isDistC2M       (isDC2M),
   isFocaleFree    (false),
   isPPFree        (false),
   isAFoc1Free     (false),
   isAFoc2Free     (false),
   mCamInit        (aCamInit),
   mCurPIF         (0),
   mCamGrid        (0),
   mFiged          (false),
   mFocaleInit     (mCamInit->Focale()),
   mCurFocale      (mFocaleInit),
   mPPInit         (mCamInit->PP()),
   mCurPP          (mPPInit),
   mAFocInit       (mCamInit->ParamAF()),
   mCurAFoc        (mAFocInit),
   mFFoc           (  ParamVar ?
		      aSet.Alloc().NewF(&mCurFocale) :
		      Fonc_Num(mFocaleInit)
		   ),
   mIndPP          (aSet.Alloc().CurInc()),
   mFPP            (
		        ParamVar ?
		        aSet.Alloc().NewPt2(mCurPP) :
		        Pt2d<Fonc_Num>(mPPInit.x,mPPInit.y)
                   ),
   mIndAF          (aSet.Alloc().CurInc()),
   mFAFoc           (aSet.Alloc().NewVectInc(mCurAFoc)),
   mParamVar        (ParamVar),
   mTolFoc          (cContrainteEQF::theContrStricte),
   mTolPP           (cContrainteEQF::theContrStricte),
   mTolAF1          (cContrainteEQF::theContrStricte),
   mTolAF2          (cContrainteEQF::theContrStricte),
   mProjStenF       (mFFoc,mFPP.x,mFPP.y,mFAFoc),
   mRegulDistDxyP1     (new cP2d_Etat_PhgrF("RegDistxy1")),
   mRegulDistDxyP2     (new cP2d_Etat_PhgrF("RegDistxy2")),
   mRegulDistDxyP3     (new cP2d_Etat_PhgrF("RegDistxy3")),
   mRegulDistDxyP4     (new cP2d_Etat_PhgrF("RegDistxy4")),

   mRegulDistDxxP1     (new cP2d_Etat_PhgrF("RegDistuu1")),
   mRegulDistDxxP2     (new cP2d_Etat_PhgrF("RegDistuu2")),
   mRegulDistDxxP3     (new cP2d_Etat_PhgrF("RegDistuu3")),

   // mRegulDistDyyP1     (new cP2d_Etat_PhgrF("RegDistuu1")),
   // mRegulDistDyyP2     (new cP2d_Etat_PhgrF("RegDistuu2")),
   // mRegulDistDyyP3     (new cP2d_Etat_PhgrF("RegDistuu3")),

   mRegulDistDxP1      (new cP2d_Etat_PhgrF("RegDistu1")),
   mRegulDistDxP2      (new cP2d_Etat_PhgrF("RegDistu2")),
   mRegulDistKnownDer  (new cP2d_Etat_PhgrF("RegDistu3")),

   // mRegulDistDyP1      (new cP2d_Etat_PhgrF("RegDistu1")),
   // mRegulDistDyP2      (new cP2d_Etat_PhgrF("RegDistu2")),

   mRegulDistValP1     (new cP2d_Etat_PhgrF("RegDistValP1")),
   mRegulDistKnownVal  (new cP2d_Etat_PhgrF("RegDistKnownVal")),

   mFER_DxDy        (0),
   mFER_Dxx         (0),
   mFER_Dx          (0),
   mFER_Val         (0),
   mImPdsDef        (1,1,1.0)
{
  NV_UpdateCurPIF();
}
cEqCalibCroisee::cEqCalibCroisee
(
       bool                      SensC2M,
       cParamIntrinsequeFormel & aPIF,
       cRotationFormelle *       aRot,
       bool                      Code2Gen
)  :
   mSet       (*aPIF.Set()),
   mPIF       (aPIF),
   mRotCalc   ( aRot ? 
                aRot :
                mSet.NewRotation(eRotCOptFige,ElRotation3D(Pt3dr(0,0,0),0,0,0))
              ),
   mRot2Destr (aRot ? 0 : mRotCalc),
   mP1        ("PIm1"),
   mN2        ("DirEsp2"),
   mResidu    (   SensC2M ?
                  (    PointNorm1(mPIF.Cam2DirRayMonde(mP1.PtF(),0))
                       - mRotCalc->VectM2C(mN2.PtF())
                  )  :
		  AdZ0(mP1.PtF() -mPIF.DirRayMonde2Cam(mRotCalc->VectM2C(mN2.PtF()),0))
              ),
   mNameType  ("cEqCalibCroisee_" +  mPIF.NameType() +"_CodGen" + std::string(SensC2M ? "C2M" : "M2C"))
{

    // Test de coherence, si rotation vient de l'exterieur
    ELISE_ASSERT
    (
        (&mSet==mRotCalc->Set()),
        "Set incoherence in cEqObsRotVect::cEqObsRotVect"
    );

   // En mode utilisation,  assurele lien les numeros d'inconnu de mRotCalc et 
   // la numerotation interne; en mode generation de code cree l'intervale de ref
     mRotCalc->IncInterv().SetName("Orient");
     mPIF.IncInterv().SetName("Calib");
     mLInterv.AddInterv(mRotCalc->IncInterv());
     mLInterv.AddInterv(mPIF.IncInterv());

    // Cette etape va creer  un objet de type "cEqCalibCroisee_Calib_CodeGen",
    // tant que le code n'a pas ete genere et linke, il n'y a aucune
    // raison pour que cet objet puisse etre cree, la valeur 0 sera alors
    // retournee
    mFoncEqResidu = cElCompiledFonc::AllocFromName(mNameType);


    if (Code2Gen)
    {
        GenCode();
        // En phase de generation il n'y a pas grand chose de plus a faire
        return;
    }

    // En theorie le mecanisme permet de fonctionner meme sans generation
    // de code par un mode degrade "interprete" ou toute les evaluation sont
    // faite directement a partir des Fonc_Num ;  cette fonctionnalite n'est
    // pas vraiment maintenue (par exemple elle ne gere par les contraintes
    // multiple);  on conserve l'architecture de code  "au cas ou "mais 
    // on en interdit l'usage

    if (mFoncEqResidu==0)
    {
       std::cout << "Name = " << mNameType << "\n";
       ELISE_ASSERT(false,"Can Get Code Comp for cEqCalibCroisee");      
       mFoncEqResidu = cElCompiledFonc::DynamicAlloc(mLInterv,Fonc_Num(0));
    }

    // Cree dans l'objet la lut vers les numero d'inconnues
    mFoncEqResidu->SetMappingCur(mLInterv,&mSet);


    // Le code genere fait reference au valeur de P1 et P2;
    // pour pouvoir repidement faire l'initialisation on memorise
    // leur adresse (on envoie un nom, on recupere une adresse)
    // ceci est encapsule dans cP3d_Etat_PhgrF qui gere les variables
    // d'etat triple correspondant des points 3D
    mP1.InitAdr(*mFoncEqResidu);
    mN2.InitAdr(*mFoncEqResidu);

    aPIF.InitStateOfFoncteur(mFoncEqResidu,0);

    // Il est necessaire que  mSet connaisse l'ensemble de ses "foncteur"
    // pour  :
    //    1- assurer la mise a jour des inconnues dans le cas d'un processus iteratif
    //    2- assurer la destruction

    mSet.AddFonct(mFoncEqResidu);
}
cEqObsRotVect::cEqObsRotVect
(
       cSetEqFormelles &   aSet,
       cRotationFormelle * aRot,
       bool                Code2Gen
)  :
   mSet       (aSet),
   mRotCalc   ( aRot ? 
                aRot :
                aSet.NewRotation(eRotCOptFige,ElRotation3D(Pt3dr(0,0,0),0,0,0))
              ),
   mRot2Destr (aRot ? 0 : mRotCalc),
   mN1        ("P1"),
   mN2        ("P2"),
   mResidu    (mRotCalc->VectC2M(mN1.PtF())-mN2.PtF()),
   mNameType  ("cEqObsRotVect_CodGen")
{

    ELISE_ASSERT
    (
        (&mSet==mRotCalc->Set()),
        "Set incoherence in cEqObsRotVect::cEqObsRotVect"
    );

   // En mode utilisation,  assurele lien les numeros d'inconnu de mRotCalc et 
   // la numerotation interne; en mode generation de code cree l'intervale de ref
     mRotCalc->IncInterv().SetName("Orient");
     mLInterv.AddInterv(mRotCalc->IncInterv());

    // Cette etape va creer  un objet de type "cEqObsRotVect_CodGen",
    // tant que le code n'a pas ete genere et linke, il n'y a aucune
    // raison pour que cet objet puisse etre cree, la valeur 0 sera alors
    // retournee
    mFoncEqResidu = cElCompiledFonc::AllocFromName(mNameType);


    if (Code2Gen)
    {
        GenCode();
        // En phase de generation il n'y a pas grand chose de plus a faire
        return;
    }

    // En theorie le mecanisme permet de fonctionner meme sans generation
    // de code par un mode degrade "interprete" ou toute les evaluation sont
    // faite directement a partir des Fonc_Num ;  cette fonctionnalite n'est
    // pas vraiment maintenue (par exemple elle ne gere par les contraintes
    // multiple);  on conserve l'architecture de code  "au cas ou "mais 
    // on en interdit l'usage

    if (mFoncEqResidu==0)
    {
       ELISE_ASSERT(false,"Can Get Code Comp for cCameraFormelle::cEqAppui");      
       mFoncEqResidu = cElCompiledFonc::DynamicAlloc(mLInterv,Fonc_Num(0));
    }

    // Cree dans l'objet la lut vers les numero d'inconnues
    // reduits (ici [0,3[)
    mFoncEqResidu->SetMappingCur(mLInterv,&mSet);


    // Le code genere fait reference au valeur de P1 et P2;
    // pour pouvoir repidement faire l'initialisation on memorise
    // leur adresse (on envoie un nom, on recupere une adresse)
    // ceci est encapsule dans cP3d_Etat_PhgrF qui gere les variables
    // d'etat triple correspondant des points 3D
    mN1.InitAdr(*mFoncEqResidu);
    mN2.InitAdr(*mFoncEqResidu);


    // Il est necessaire que  mSet connaisse l'ensemble de ses "foncteur"
    // pour  :
    //    1- assurer la mise a jour des inconnues dans le cas d'un processus iteratif
    //    2- assurer la destruction

    mSet.AddFonct(mFoncEqResidu);
}