Ejemplo n.º 1
0
Im1D_U_INT1 ImMajic()
{
	static Im1D_U_INT1 res(1);
	static bool First = true;
	if (First)
	{
		First = false;
		const char * majic = "krznp re9pjsuquk8peyk9mcnbwlmqopa6teyioptrenslohteapoiutegnm";
		res = Im1D_U_INT1( (int)strlen(majic) );

		for ( INT x=0; x<res.tx(); x++ )
			res.data()[x] = majic[x];
	}
	return res;
}
Ejemplo n.º 2
0
void cGenSysSurResol::GSSR_AddContrainteIndexee
     (
         const std::vector<int> & aVI,
         REAL * aC,
         REAL aE
      )
{
    AssertPhaseContrainte();
 
 // Gestion specifique des contraintes univariees
   if ((! mNewCstrIsInit) && mUseSpeciCstrUniVar)
   {
       mIsCstr = Im1D_U_INT1(NbVar(),0);
       mDIsCstr = mIsCstr.data();
       mValCstr = Im1D_REAL8(NbVar(),0.0);
       mDValCstr = mValCstr.data();
       mNewCstrIsInit = true;
   }
   else
   {
       ELISE_ASSERT(mValCstr.tx()==NbVar(),"Sz - Incoherence in GSSR_AddContrainte");
   }
   int aNbVarNN = 0;
   int aKNN = -1;
   for (int y=0 ; y<int(aVI.size()) ; y++)
   {
       if (aC[y] !=0)
       {
            aNbVarNN++;
            aKNN = y;
       } 
   }


   if ((aNbVarNN==1) && mUseSpeciCstrUniVar)
   {
        mDIsCstr[aVI[aKNN]] = 1;
        mValCstr.data()[aVI[aKNN]] = aE/aC[aKNN];
       // std::cout << "xrt-CSTR[" << aVI[aKNN] <<"] = "  << aE/aC[aKNN]   << " C=" << aC[aKNN] << "\n";
        return;
   }
           

 // Gestion des contrainte l'ancienne si pas univariee

    mNbContrainte++;
    // Premiere contrainte
    if (mNbContrainte == 1)
    {
       ELISE_ASSERT(AcceptContrainteNonUniV(),"Ce systeme n'accepte que les contraintes uni var");
       mC.set_to_size(NbVar(),NbVar());
       mE.set_to_size(1,NbVar());
       // a priori inutile, mais pour initialiser toujours
       for (int y=0 ; y<NbVar() ; y++)
           mE(0,y) = 0;
       mtL.set_to_size(NbVar(),1);
       mtLC.set_to_size(NbVar(),1);
       mSol.set_to_size(1,NbVar());
       mCSol.set_to_size(1,NbVar());
    }
    mLineCC = NbVar() -mNbContrainte;
    ELISE_ASSERT(mLineCC>=0,"Too much contrainte in cGenSysSurResol");

    for (INT aV=0; aV<NbVar(); aV++)
    {
        mC(aV,mLineCC) = 0;
    }
    for (int y=0 ; y<int(aVI.size()) ; y++)
    {
        mC(aVI[y],mLineCC) = aC[y];
    }
    mE(0,mLineCC) = aE;
}