Ejemplo n.º 1
0
int main(int argc, char *argv[]) {
//	poczatkowo pusta lista
	struct Lista* MojaLista=NULL;
	struct Lista* MojaLista1=NULL;
	struct Lista* MojaLista2=NULL;
	int i;
	for(i=1;i<11;i++) MojaLista=dodaj(MojaLista,i,i);
	for(i=11;i<21;i++) MojaLista1=dodaj(MojaLista1,i,i);
	for(i=21;i<31;i++) MojaLista2=dodaj(MojaLista2,i,i);
	printf("wypelniamy wszystkie 3 listy i wyswietlamy\n");
	printf("lista1\n");
	wyswietl(MojaLista);
	printf("lista2\n");
	wyswietl(MojaLista1);
	printf("lista3\n");
	wyswietl(MojaLista2);
	printf("szukamy jakas wartosc w liscie\n");
	szukaj(MojaLista,1.0,1.0);
	szukaj(MojaLista,12,14);
	printf("usuwamy jakas wartosc w liscie\n");
	MojaLista=usun(MojaLista,1,1);
	MojaLista=usun(MojaLista,10,10);
	MojaLista=usun(MojaLista,5,5);

	printf("scalamy liste 2 i 3 z zapisem w 1 oraz kasowaniem list\n");
	MojaLista=scal(MojaLista,MojaLista1,MojaLista2);	
	MojaLista1=kasuj(MojaLista1);
	MojaLista2=kasuj(MojaLista2);
	wyswietl(MojaLista);
	wyswietl(MojaLista1);
	wyswietl(MojaLista2);
	return 0;
}
Pt3dr cMEPCoCentrik::ComputeBase()
{
    Pt3dr aBest(0,0,0);
    double aScoreMin = 1e20;

    for (int aK1=0 ; aK1<int(mVPlanBase.size()); aK1++)
    {
         Pt3dr aCdtBase = mVPlanBase[aK1];
         double aScore = 0;
         for (int aK2=0 ; aK2<int(mVPlanBase.size()); aK2++)
         {
               Pt3dr aP2 = mVPlanBase[aK2];
               if (scal(aP2,aCdtBase) < 0) aP2 = -aP2;
               double aDist = euclid(aP2-aCdtBase);
               aDist =  CoutAttenueTetaMax(aDist,0.3);
               aScore += aDist;
         }
         if (aScore < aScoreMin)
         {
              aScoreMin = aScore;
              aBest = aCdtBase;
         }
    }
    return aBest;
}
void cASAMG::ComputeIncidAngle3D()
{
   cRawNuage   aRN = mStdN->GetRaw();
   Pt2di aP0;

   Im2D_Bits<1> aMasqTmp = ImMarqueurCC(mSz);
   TIm2DBits<1> aTMasqTmp(aMasqTmp);


   for (aP0.x=0 ; aP0.x<mSz.x ; aP0.x++)
   {
       for (aP0.y=0 ; aP0.y<mSz.y ; aP0.y++)
       {
            double Angle = 1.5;
            if (mTMasqN.get(aP0))
            {
                cCalcPlanEuclid  aCalcPl(CCDist(),aRN);
                int aNb = OneZC(aP0,CCV4(),aTMasqTmp,1,0,mTMasqN,1,aCalcPl);
                ResetMarqueur(aTMasqTmp,aCalcPl.mVPts);
                if (aNb >= SeuimNbPtsCCDist())
                {
                    cElPlan3D aPlan(aCalcPl.mVP3,0);
                    // ElSeg3D aSeg(aC0,mStdN->GetPt(aP0));
                    ElSeg3D aSeg =  mStdN->FaisceauFromIndex(Pt2dr(aP0));
                    double aScal = scal(aPlan.Norm(),aSeg.TgNormee());
                    if (aScal<0) aScal = - aScal;
                    Angle = acos(ElMin(1.0,ElMax(-1.0,aScal)));
                }
            }
            mTIncid.oset(aP0,ElMin(255,ElMax(0,round_ni(Angle*DynAng()))));
       }
   }
}
         Pt3dr cElN3D_EpipGen<Type,TBase>::Loc_IndexAndProf2Euclid(const Pt2dr & anI,const double & anInvProf) const
{

  if (mProfIsZ) 
  {
       // std::cout << anInvProf << " " << anI << " "  << this->mCam->F2AndZtoR3(anI,anInvProf)  << "\n";
      return  this->mCam->F2AndZtoR3(anI,anInvProf);
  }

   double aProf =   CorZInv(anInvProf);


   if (mIsSpherik)
   {
       return mCS->ImEtProfSpherik2Terrain(anI,aProf);
   }


    ElSeg3D aSeg =  this->mCam->F2toRayonR3(anI) ;
    Pt3dr aRay =aSeg.Tgt();
    Pt3dr aC  = aSeg.P0();

   return   aC
          + aRay * (aProf/scal(aRay,mDirPl));
}
Ejemplo n.º 5
0
template <class T> INT get_best_intexe(const ElFifo<T> & fp,bool EnvConv)
{
   if (! fp.circ())
      return 0;

   if (fp.nb() < 4)
      return 0;


   INT delta = EnvConv ? 1 : std::min(5,(fp.nb()-2)/2);
   REAL min_cos = 10.0;
   INT best_index = 0;

   std::vector<INT> aVOk;
   std::vector<INT> aVPrec;
   std::vector<INT> aVSucc;

   for(INT aK=0 ; aK<INT(fp.size()) ; aK++)
   {
       aVOk.push_back(EnvConv ? 0 : 1);
       aVPrec.push_back(aK-delta);
       aVSucc.push_back(aK+delta);
   }
   if (EnvConv)
   {
      ElFilo<Pt2dr> aFLP;
      for(INT aK=0 ; aK<INT(fp.size()) ; aK++)
         aFLP.pushlast(fp[aK]);
      ElFifo<INT> Ind;
      env_conv(Ind,aFLP,true);
      for (INT aK=0 ; aK<Ind.nb() ; aK++)
      {
          aVOk[Ind[aK]] = 1;
          aVPrec[Ind[aK]] = Ind[(aK-1+Ind.nb())%Ind.nb()];
          aVSucc[Ind[aK]] = Ind[(aK+1)%Ind.nb()];
      }
   }

   for (INT k =0 ; k<fp.nb() ; k++)
   {
       if (aVOk[k])
       {
            T u1 = fp[k]-fp[aVPrec[k]];
            T u2 = fp[aVSucc[k]]-fp[k];
            double d1 = euclid(u1);
            double d2 = euclid(u2);
            if (d1 && d2)
            {
               double cosin = scal(u1,u2) / (d1*d2);
               if (cosin < min_cos)
               {
                  min_cos = cosin; 
                  best_index = k;
               }
            }
       }
   }
   return best_index ;
}
Ejemplo n.º 6
0
int scal( //
		const TYPE& sa,       //[in]
		ArrayListV<TYPE>& asx //[in,out]
		) {
	int n = asx.size();
	TYPE* sx = asx.getPointer();
	return scal(n, sa, sx, 1);
}
Ejemplo n.º 7
0
static Pt3dr  PInBCoord(const Pt3dr & aBase,const ElMatrix<double> & aRot,const Pt3dr & aPA)
{
  // mDirOr1A (vunit(mBase^mDir1A)),
    Pt3dr aRes =  aRot.transpose() * (aBase+aPA);

     std::cout << "PInBCoord " << scal(aBase^aPA,aRot*aRes) << "\n";
    return aRes;
}
Ejemplo n.º 8
0
/* elementary row operation: scale a row by some factor */
void el_scale(size_t n, num *equation, size_t r, num c)
{
    if (!c) {
        fprintf(stderr, "multiplying a row by 0 is disallowed\n");
        abort();
    }
    scal(n + 1, c, equation + r * (n + 1));
}
Ejemplo n.º 9
0
double cLiaisORPO::Residu()
{
    SetOrCam();
    if (! mProfCalc)
    {
       mProfCalc = true;
       SetProf();
    }

    // ElRotation3D aC1toM = mCam1.Orientation().inv();
    // ElRotation3D aMtoC2 = mCam2.Orientation();

    ElRotation3D  aC1toC2 =  mCam2.Orient() *  mCam1.Orient().inv();

    Pt3dr aBaseInC2 = aC1toC2.ImAff(Pt3dr(0,0,0));

    ElMatrix<double> aMat =  aC1toC2.Mat() ;

    Pt3dr aC0,aC1,aC2;
    aMat.GetCol(0,aC0);
    aMat.GetCol(1,aC1);
    aMat.GetCol(2,aC2);


    double sDist=0.0;
    int aK = 0;

    for (ElPackHomologue::const_iterator itP =mPack.begin() ; itP!=mPack.end(); itP++)
    {
       double aPds = itP->Pds();
       double aLambda =  mProfs.at(aK);

        Pt2dr aPIm1 = itP->P1();
        Pt3dr aRay1 = aC0 * aPIm1.x + aC1 * aPIm1.y + aC2;


        Pt3dr aPTerA = aBaseInC2 + aRay1 * (aLambda *0.99);
        Pt3dr aPTerB = aBaseInC2 + aRay1 * (aLambda *1.01);

        Pt2dr aProjA(aPTerA.x/aPTerA.z,aPTerA.y/aPTerA.z);
        Pt2dr aProjB(aPTerB.x/aPTerB.z,aPTerB.y/aPTerB.z);

         Pt2dr aVAB  (aProjB.y-aProjA.y,aProjA.x-aProjB.x);

         double aD2 =  ElAbs(scal(aVAB,aProjA-itP->P2()) / euclid(aVAB));
         sDist += aPds*aD2;

         aK++;
    }

    if (DEBUG_POWEL)
    {
        std::cout << sDist/mPack.size() << "\n"; // getchar();
    }

    return sDist * mPPL->Pds().Val();
}
Ejemplo n.º 10
0
void ScreenCapSetting::on_pushButton_applyOptions_clicked()
{
	QString bits(ui.comboBox_bits->currentText().split(" ")[0]);
	QString	scal(ui.comboBox_scaling->currentText().split(" ")[0]);
	QString refresh(ui.comboBox_refresh->currentText().split(" ")[0]);
	
	emit ApplyOptions(bits, scal, refresh);

	close();
}
Ejemplo n.º 11
0
Transform SWPhysics::toSWTransform(btTransform& o) {
    Transform ret;
    Vector3f trans(o.getOrigin().getX(), o.getOrigin().getY(), o.getOrigin().getZ());
    Vector3f rot(o.getRotation().getX(), o.getRotation().getY(), o.getOrigin().getZ());
    Vector3f scal(1);
    ret.setTranslate(trans);
    ret.setRotate(rot);
    ret.setScale(scal);
    return ret;
}
Ejemplo n.º 12
0
ElMatrix<double> cOriFromBundle::CalculRot(const cOFB_Sol1S1T & aSol,bool Show)
{
   // R [mDir1B ...] = [mV1 ...]

    ElMatrix<double>  aMatB =     MatFromCol(mDir1B,mDir2B,mDir3B);
    ElMatrix<double> aMatBinA =   MatFromCol(aSol.mV1,aSol.mV2,aSol.mV3);
    ElMatrix<double> aMat = aMatBinA * gaussj(aMatB);

// std::cout << mDir1B << mDir2B << mDir3B << "\n";
// std::cout << aSol.mV1 << aSol.mV2 << aSol.mV3 << "\n";
// std::cout << "xxxxxxxxxxxx\n";
/*
    for (int anY=0 ; anY<3 ; anY++)
    {
        for (int anX=0 ; anX<3 ; anX++)
        {
            std::cout << aMat(anX,anY) << " ";
        }
        std::cout << "\n";
    }
*/
// getchar();




    ElMatrix<double> aR = NearestRotation(aMat);
// std::cout << "yyyyyyyyyyyyyy\n";


    if (Show)
    {
        std::cout << "DET " << aR.Det() -1.0  << " Eucl " << ElMatrix<double>(3,true).L2(aR*aR.transpose())<< "\n";
        std::cout  << " SCAL " << scal(mBase^mDir1A,aR*mDir1B)  << " "
                               << scal(mBase^mDir2A,aR*mDir2B)  << " "
                               << scal(mBase^mDir3A,aR*mDir3B)  << "\n";
            
    }
    
    return aR;
}
Ejemplo n.º 13
0
bool seg_prim_inside
     (
           const SegComp & s,
           Pt2dr pt,
           SegComp::ModePrim mode
     )
{

    switch(mode)
    {
         case SegComp::droite :
              return true;

         case SegComp::demi_droite :
              return (scal(pt-s.p0(),s.tangente()) > 0) ;

         default :
              return  (scal(pt-s.p0(),s.tangente()) <s.length()) 
                   && (scal(pt-s.p0(),s.tangente()) > 0)         ;
    }
}
Ejemplo n.º 14
0
void bi::var(const M1 X, const V1 mu, V2 sigma) {
  /* pre-conditions */
  BI_ASSERT(X.size2() == mu.size());
  BI_ASSERT(sigma.size() == mu.size());

  const int N = X.size1();
  typename sim_temp_matrix<M1>::type Z(X.size2(), X.size1());
  Z = X;
  sub_rows(Z, mu);
  dot_columns(Z, sigma);
  scal(1.0/(N - 1.0), sigma);
}
Ejemplo n.º 15
0
cOriFromBundle::cOriFromBundle
(
      Pt3dr aBase,
      Pt3dr aDir1A,
      Pt3dr aDir2A,
      Pt3dr aDir3A,
      Pt3dr aDir1B,
      Pt3dr aDir2B,
      Pt3dr aDir3B
) :
  mBase    (vunit(aBase)) ,
  mDir1A   (vunit(aDir1A)),
  mDir2A   (vunit(aDir2A)),
  mDir3A   (vunit(aDir3A)),
  mDirOr1A (vunit(mBase^mDir1A)),
  mDirOr2A (vunit(mBase^mDir2A)),
  mDirOr3A (vunit(mBase^mDir3A)),
  mDir1B   (vunit(aDir1B)),
  mDir2B   (vunit(aDir2B)),
  mDir3B   (vunit(aDir3B)),
  mSc12    (scal(mDir1B,mDir2B)),
  mZB      (vunit(mDir1B^mDir2B)),
  mYB      (vunit(mZB^mDir1B)),
  mSc3X    (scal(mDir3B,mDir1B)),
  mSc3Y    (scal(mDir3B,mYB)),
  mSc3Z    (scal(mDir3B,mZB)),
  mX12     (vunit(mDirOr1A^mDirOr2A)),
  mY1      (vunit(mDirOr1A^mX12)),
  mZ1      (mX12 ^ mY1),
  mY2      (vunit(mDirOr2A^mX12)),
  mCosY2   (scal(mY2,mY1)),
  mSinY2   (scal(mY2,mZ1))
{
}
Ejemplo n.º 16
0
void cLiaisORPO::SetProf()
{
   mProfs.clear();
   Pt3dr aC1 = mCam1.PseudoOpticalCenter();
   for(ElPackHomologue::iterator itP=mPack.begin();itP!=mPack.end();itP++)
   {
       Pt3dr aPTer = mCam1.PseudoInter(itP->P1(),mCam2,itP->P2());
       mProfs.push_back
       (
           scal(aPTer-aC1,mCam1.F2toDirRayonR3(itP->P1()))
       );
   }
}
int main(void)
{
	char a[]="jeden";
	char b[]="dwa";
	char *wynik;
	
	wynik = scal(a, b);

	printf("%s+%s=%s\n", a, b, wynik);

	free(wynik);

	return 0;
}
Ejemplo n.º 18
0
int	main(int ac, char **av)
{
    if (debut(ac, av[1]) == 0 && atoi(av[1]) > 0 && (av[2][0] >= 49 && av[2][0] <= 57))
    {
        srand(time(NULL));
        int a = atoi(av[2]);
        int b = rand()%(9+10)-9;
        int tabA[a], tabB[a] , tabAB[a], tabMult[a];
        printf("Vecteur A:\t");
        nbrAlea(a, tabA);
        affiche(tabA, a);
        printf("\n");
        if (atoi(av[1]) != 2)
        {
            printf("Vecteur B:\t");
            nbrAlea(a, tabB);
            affiche(tabB, a);
            printf("\n");
        }
        if (atoi(av[1]) == 1)
        {
            printf("Vecteur A+B:\t");
            somme(a, tabA, tabB, tabAB);
            affiche(tabAB, a);
        }
        else if (atoi(av[1]) == 2)
        {
            printf("   B: %d\nVecteur A*B:\t", b);
            multi(a, tabA, tabMult, b);
            affiche(tabMult, a);
        }
        else if (atoi(av[1]) == 3)
        {
            printf("Produit Scalaire AB:\t");
            printf("%d", scal(a, tabA, tabB));
        }
        else if (atoi(av[1]) == 4)
        {
            printf("Norme Euclidienne A.B:\t");
            somme(a, tabA, tabB, tabAB);
            printf("%.3f", sqrt(norme(a, tabAB)));
        }
        printf("\n");

    }
    else
        printf("Veuillez entrer en argument un nombre compris entre 1 et 4 suivi du nombre de coordonnee que vous voulez \n");
    return (0);

}
Ejemplo n.º 19
0
bool RosenbrockDaeDefinition::numericalJacVec(const Vec& v, Vec& Jv)
{
    bool evalError=false;
    real delFac=1.0e-5;
    value(evalError);//sets Fcurrent
    if (evalError)
        return evalError;
    else
    {
//cek       del = -delFac*v;
        del = v;
        scal(-delFac,del);
        //end cek
        correctArgument(del);//sets Flast to Fcurrent --
        //remember correction is -del = delFac*v
        value(evalError);
        while (evalError)
        {
            std::cerr<<"cutting back on del in numerical jac vec"<<std::endl;
            unCorrect();//sets Flast to Fcurrent
            delFac*=0.1;
//cek           del = -delFac*v;
            del = v;
            scal(-delFac,del);
            //end cek
            correctArgument(del);
            value(evalError);//sets Fcurrent
        }
//cek      Jv = (Fcurrent - Flast)/delFac;
        Jv = Fcurrent;
        axpy(-1.0,Flast,Jv);
        scal(delFac,Jv);
        //end cek
        unCorrect();
    }
    return evalError;
}
Ejemplo n.º 20
0
REAL IntersecSegCercle(const SegComp &aSeg,Pt2dr & Q0,Pt2dr & Q1)
{
    Pt2dr T = aSeg.tangente();
    Pt2dr p0 = aSeg.p0();

    REAL a =  square_euclid(T);
    REAL b = 2 * scal(T,p0);
    REAL c = square_euclid(p0) - 1;
    REAL delta = ElSquare(b) - 4 * a * c;
    REAL SqDelta = sqrt(ElMax(0.0,delta));

    Q0  = p0 + T*((-b-SqDelta)/(2*a));
    Q1  = p0 + T*((-b+SqDelta)/(2*a));

    return delta;
}
Ejemplo n.º 21
0
//Calcule et stocke l'angle entre Dir et Triangle (appartenant a TriIdx)
void cMesh::setTrianglesAttribute(int img_idx, Pt3dr Dir, vector <unsigned int> const &aTriIdx)
{
    for (unsigned int aK=0; aK < aTriIdx.size(); aK++)
    {
        cTriangle *aTri = getTriangle(aTriIdx[aK]);

        Pt3dr aNormale = aTri->getNormale(true);

        double cosAngle = scal(Dir, aNormale) / euclid(Dir);

        vector <double> vAttr;
        vAttr.push_back(cosAngle);

        aTri->setAttributes(img_idx, vAttr);
    }
}
Ejemplo n.º 22
0
void
scal(const Kokkos::View< RT,RL,RD,RM,Kokkos::Impl::ViewMPVectorContiguous >& r,
     const typename Kokkos::View< XT,XL,XD,XM,Kokkos::Impl::ViewMPVectorContiguous >::non_const_value_type& a,
     const Kokkos::View< XT,XL,XD,XM,Kokkos::Impl::ViewMPVectorContiguous >& x)
{
  typedef Kokkos::Impl::ViewMPVectorContiguous S;
  typedef Kokkos::View< XT,XL,XD,XM,S > XVector;
  typedef Kokkos::View< RT,RL,RD,RM,S > RVector;

  if (!Sacado::is_constant(a)) {
    Kokkos::Impl::raise_error("scal not implemented for non-constant a");
  }

  typename XVector::flat_array_type x_flat = x;
  typename RVector::flat_array_type r_flat = r;
  scal( r_flat, a.coeff(0), x_flat );
}
Ejemplo n.º 23
0
Pt2di second_freeman_approx(Pt2di u, bool conx_8,Pt2di u1)
{
     Pt2di u2;

     if(u1^u)
     {
        u2 = best_4_approx(u - u1 * scal(u,u1));  // first suppose not 4 cone xity
        if (conx_8)  // eventually correct if 8 conne xity
           u2 = u1+u2;
      }
      // if u is horizontal or vertical (wich is equivalent to u colinear to u1)
     //  the previous line mail fail (because take best_4_approx of (0,0) may give
     // u1). So simply set :
      else
         u2 = u1;

   return u2;
}
Ejemplo n.º 24
0
typename std::enable_if<
  Kokkos::is_view_mp_vector< Kokkos::View<RD,RP...> >::value &&
  Kokkos::is_view_mp_vector< Kokkos::View<XD,XP...> >::value >::type
scal(const Kokkos::View<RD,RP...>& r,
     const typename Kokkos::View<XD,XP...>::non_const_value_type& a,
     const Kokkos::View<XD,XP...>& x)
{
  typedef Kokkos::View<RD,RP...> RVector;
  typedef Kokkos::View<XD,XP...> XVector;

  if (!Sacado::is_constant(a)) {
    Kokkos::Impl::raise_error("scal not implemented for non-constant a");
  }

  typename Kokkos::FlatArrayType<XVector>::type x_flat = x;
  typename Kokkos::FlatArrayType<RVector>::type r_flat = r;
  scal( r_flat, a.coeff(0), x_flat );
}
Ejemplo n.º 25
0
void L2SysSurResol::GSSR_Add_EqInterPlan3D(const Pt3dr& aDirOrtho,const Pt3dr& aP0,double aPds)
{
   static std::vector<int> aVInd;
   if (aVInd.empty())
   {
      aVInd.push_back(0);
      aVInd.push_back(1);
      aVInd.push_back(2);
   }
   double aCoeff[3];
   // Pt3dr aD = vunit(aDirOrtho);
   // std::cout << euclid(aDirOrtho) << "\n";
   aCoeff[0] =  aDirOrtho.x;
   aCoeff[1] =  aDirOrtho.y;
   aCoeff[2] =  aDirOrtho.z;

   //GSSR_AddNewEquation(aPds,aCoeff,scal(aDirOrtho,aP0),0);
    L2SysSurResol::V_GSSR_AddNewEquation_Indexe(0,0,0,aVInd,aPds,&(aCoeff[0]),scal(aDirOrtho,aP0));
}
template <class Type,class TBase>  cElN3D_EpipGen<Type,TBase>::cElN3D_EpipGen
(
        const std::string &             aDir,
        const cXML_ParamNuage3DMaille & aNuage,
        Fonc_Num  aFMasq,
        Fonc_Num  aFProf,
        bool      aProfIsZ,
        bool      WithEmptyData,
        bool      Dequant

)  :
   cElNuage3DMaille_FromImProf<Type,TBase>(aDir,aNuage,aFMasq,aFProf,WithEmptyData,Dequant), 
   mProfIsZ   (aProfIsZ)
{
	mCentre	   = this->mCam->OrigineProf();
	mDirPl	   = this->Params().DirFaisceaux();
	mZIsInv    = this->Params().ZIsInverse();
	mIsSpherik = this->Params().IsSpherik().Val();
	mCS        = (mIsSpherik ? this->mCam->CS() : 0);
	mProfC     = scal(mDirPl,mCentre);
}
Ejemplo n.º 27
0
void A2L::fillScalarsInfo(QVector< QSharedPointer<ECUScalar> > &scalars) const {

    for ( ptrdiff_t i=0; i<m_scalarsInfo.size(); i++ ) {

        QSharedPointer<ECUScalar> scal(new ECUScalar());

        const ptrdiff_t compuMethodInd = findCompuMethod(m_scalarsInfo[i][6]);

        if ( m_compumethodsInfo[compuMethodInd][2] == "RAT_FUNC" ) {

            scal->setType(VARTYPE_SCALAR_NUM);
            scal->setCoefficients(getCoeff(compuMethodInd));
        }
        else if ( m_compumethodsInfo[compuMethodInd][2] == "TAB_VERB" ) {

            scal->setType(VARTYPE_SCALAR_VTAB);

            const ptrdiff_t compuVTabInd = findCompuVTab(m_compumethodsInfo[compuMethodInd][5].split(' ').last());
            scal->setVTable(getVTab(compuVTabInd));
        }

        scal->setName(m_scalarsInfo[i][0]);
        scal->setShortDescription(delQuotes(m_scalarsInfo[i][1]));
        scal->setAddress(m_scalarsInfo[i][3].split("x").last());
        scal->setNumType(m_scalarsInfo[i][4].split('_').last());
        scal->setRangeSoft(m_scalarsInfo[i][5].toDouble());
        scal->setMinValueSoft(m_scalarsInfo[i][7].toDouble());
        scal->setMaxValueSoft(m_scalarsInfo[i][8].toDouble());
        scal->setPrecision(delQuotes(m_scalarsInfo[i][9].split('.').last()).toInt());

        QVector<double> v = getHardLimints(m_scalarsInfo[i][10]);
        scal->setMinValueHard(v[0]);
        scal->setMaxValueHard(v[1]);

        scal->setReadOnly(isReadOnly(i));
        scal->setDimension("[" + delQuotes(m_compumethodsInfo[compuMethodInd][4]) + "]");

        scalars.push_back(scal);
    }
}
void cEqPlanInconnuFormel::GenCode(const cMatr_Etat_PhgrF & aME)
{
   Pt3d<Fonc_Num> aPInc = mEqP3I->PF();
   Pt3d<Fonc_Num> aPBary = aME.Mat() * Pt3d<Fonc_Num>(aPInc.x,aPInc.y,1.0);

   Pt3d<Fonc_Num> aPZ
                  (
                     mTri->S1().ValsIncAsScal(),
                     mTri->S2().ValsIncAsScal(),
                     mTri->S3().ValsIncAsScal()
		  );

    std::vector<Fonc_Num> aVEcart;
    aVEcart.push_back(aPInc.z - scal(aPZ,aPBary));

    cElCompileFN::DoEverything
    (
        "CodeGenere/photogram/",  // Directory ou est localise le code genere
        mNameType,  // donne les noms de fichier .cpp et .h ainsi que les nom de classe
        aVEcart,  // expressions formelles 
        mLInterv  // intervalle de reference
  );
}
Ejemplo n.º 29
0
void calcDepthRange(mat4 const& pr, mat4 const& mv,
                    aabb const& bbox, float& minval, float& maxval)
{
    vec3 center = vec4( mv * vec4(bbox.center(), 1.0f) ).xyz();
    vec3 min    = vec4( mv * vec4(bbox.min, 1.0f) ).xyz();
    vec3 max    = vec4( mv * vec4(bbox.max, 1.0f) ).xyz();

    float radius = length(max - min) * 0.5f;

    // Depth buffer of ibrPlanes
    vec3 scal(center);
    scal = normalize(scal) * radius;
    min = center - scal;
    max = center + scal;

    vec4 min4 = pr * vec4(min, 1.f);
    vec4 max4 = pr * vec4(max, 1.f);

    min = min4.xyz() / min4.w;
    max = max4.xyz() / max4.w;

    minval = (min.z+1.f) * 0.5f;
    maxval = (max.z+1.f) * 0.5f;
}
Ejemplo n.º 30
0
int main(int argc, char** argv)
{
    std::vector<std::chrono::duration<double, std::milli>> duration_vector_1, duration_vector_2;

    bool run_ref = false, run_tiramisu = false;

    const char* env_ref = std::getenv("RUN_REF");
    if (env_ref != NULL && env_ref[0] == '1')
        run_ref = true;

    const char* env_tiramisu = std::getenv("RUN_TIRAMISU");
    if (env_tiramisu != NULL && env_tiramisu[0] == '1')
        run_tiramisu = true;

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
  
    double alpha = 2.5;
  
    Halide::Buffer<int> SIZES(1);
    SIZES(0) = nrow;
  
    Halide::Buffer<double> b_alpha(1);
    b_alpha(0) = alpha;
  
    Halide::Buffer<double> b_X(nrow), b_X_ref(nrow);

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------

    {
        for (int i = 0; i < NB_TESTS; ++i)
        {
            init_buffer(b_X_ref, (double)1);
            auto start = std::chrono::high_resolution_clock::now();
      
            if (run_ref)
	    	scal_ref(nrow, alpha, b_X_ref.data());
      
            auto end = std::chrono::high_resolution_clock::now();
            duration_vector_1.push_back(end - start);
        }
    }

    {
        for (int i = 0; i < NB_TESTS; ++i)
        {
            init_buffer(b_X, (double)1);
            auto start = std::chrono::high_resolution_clock::now();

            if (run_tiramisu)
	    	scal(SIZES.raw_buffer(), b_alpha.raw_buffer(), b_X.raw_buffer());

            auto end = std::chrono::high_resolution_clock::now();
            duration_vector_2.push_back(end - start);
        }
    }

    print_time("performance_cpu.csv", "scal",
	       {"Ref", "Tiramisu"},
	       {median(duration_vector_1), median(duration_vector_2)});

    if (CHECK_CORRECTNESS && run_ref && run_tiramisu)
        compare_buffers("scal", b_X_ref, b_X);

    if (PRINT_OUTPUT)
    {
        std::cout << "Tiramisu " << std::endl;
        print_buffer(b_X);

        std::cout << "Reference " << std::endl;
        print_buffer(b_X_ref);
    }
  
    return 0;
}