tSysCho cGenSysSurResol::SomQuad() const { tSysCho aRes = 0; for (int aKx=0 ; aKx<NbVar(); aKx++) { for (int aKy=0 ; aKy<NbVar(); aKy++) { aRes = ElSquare(GetElemQuad(aKx,aKy)); } } return aRes; }
void cGenSysSurResol::ShowGSR(int aMode) { for (int aKy=0 ; aKy<NbVar() ; aKy++) { for (int aKx=0 ; aKx<NbVar() ; aKx++) { double aV = GetElemQuad(aKx,aKy); if (aMode==0) { std::cout << ((aV==0) ? "-" : "*"); } else { ELISE_ASSERT(false,"cGenSysSurResol::ShowGSR"); } } std::cout << " " << aKy << " " << GetElemLin(aKy) << "\n"; // printf(" %2d L=%2e\n",aKy,GetElemLin(aKy)); //std::cout << " : " << aKy << "\n"; } }
ElMatrix<tSysCho> cGenSysSurResol::MatQuad() const { int aNbV=NbVar(); ElMatrix<tSysCho> aRes (aNbV,aNbV,0.0); for (int anX=0 ; anX<aNbV ; anX++) { for (int anY=0 ; anY<aNbV ; anY++) { aRes(anX,anY) = GetElemQuad(anX,anY); } } return aRes; }
void cGenSysSurResol::TraitementContrainteUniVar(const std::vector<int> * aVA2S) { if (! mUseSpeciCstrUniVar) return; if (! mNewCstrIsInit) return; if (mNewCstrIsTraitee) return; mNewCstrIsTraitee = true; INT NBV = NbVar(); // La premiere fois on rajoute les equations qui feront que le systeme ne sera pas // degenere for (int aKV=0 ; aKV< NBV; aKV++) { if (mDIsCstr[aKV]) { // std::cout << " YYYYYYYYYYYY : " << aKV << "\n"; std::vector<INT> aVInd; int aKI = aKV; /* if (aVA2S && (!PermutIndex)) aKI = (*aVA2S)[aKV]; */ // std::cout << "KVVVV " << aKV << " KI " << aKI << "\n"; aVInd.push_back(aKI); double aCoef1 = 1.0; Basic_GSSR_AddNewEquation_Indexe(0,0,0,aVInd,1.0,&aCoef1,mValCstr.data()[aKV]); // std::cout << "PB QUand on passe par indexee \n"; } } // std::cout << "cGenSysSurResol::TraitementContrainteUniVar \n" ; getchar(); }
Im1D_REAL8 cGenSysSurResol::GSSR_Solve(bool * aResOk) { Im1D_REAL8 aSol = V_GSSR_Solve(aResOk); if (true && (NbVar() >8)) { /* ElMatrix<double> aM2(NbVar(),NbVar()); ElMatrix<double> aL2(1,NbVar()); for (int aJ=0; aJ< NbVar() ; aJ++) { aL2(0,aJ) = GetElemLin(aJ); for (int aI=0; aI< NbVar() ; aI++) aM2(aI,aJ) = GetElemQuad(aI,aJ); } ElMatrix<double> aS2 = gaussj(aM2) * aL2; std::cout << "NBV " << NbVar() << "NB CONTRAINTE " << mNbContrainte << " Assumed : " << ContraintesAssumed() << "\n"; for (int aK=0 ; aK<NbVar() ; aK++) std::cout << "*************jjkk--- " << aK << " " << aSol.data()[aK] << " " << aS2(0,aK) << " M2 " << aM2(aK,aK) << "\n"; getchar(); */ if (0) { for (int aJ=0; aJ< NbVar() ; aJ++) { double aS0=0; for (int aK=0; aK< NbVar() ; aK++) aS0 += aSol.data()[aK] * GetElemQuad(aJ,aK); float aV = (float)GetElemLin(aJ); printf("%d %f %f %f :: ",aJ,aSol.data()[aJ],aV,aS0); for (int aK=0 ; aK< NbVar() ; aK++) { float aV = (float)GetElemQuad(aJ,aK); printf("%f ",aV); } printf("\n"); } } } if ((mNbContrainte==0) || mCstrAssumed) return aSol; for (INT y=0 ; y<NbVar() ; y++) mSol(0,y) = aSol.data()[y]; mSol += mE; mCSol.mul(mC,mSol); for (INT y=0 ; y<NbVar() ; y++) { aSol.data()[y] = mCSol(0,y); } return aSol; }
void cGenSysSurResol::GSSR_AddNewEquation (REAL aPds,REAL * aL,REAL aB,double * aCoordCur) { AssertPhaseEquation(); // ELISE_ASSERT INT NBV = NbVar(); if (mUseSpeciCstrUniVar && mNewCstrIsInit) { for (INT x=0 ; x<NBV ; x++) { if (mDIsCstr[x]) { // BUG aB += aL[x] * mDValCstr[x]; quasi indetectable car mDValCstr vaut quasi // toujours 0, car fait en delta; La magouille faite XYklTY de phgr_formel.cpp // montre que c'est bien un signe - qu'il faut ! aB -= aL[x] * mDValCstr[x]; if (aCoordCur) { aB -= aL[x] * aCoordCur[x]; } aL[x] = 0; } } } if ((mNbContrainte==0) || mCstrAssumed) { // mSetEqEmpty = false; V_GSSR_AddNewEquation(aPds,aL,aB); return; } if (mFirstEquation) { ComplBaseParLeHaut(mC,mNbContrainte); mFirstEquation = false; mGP.SelfSetMatrixInverse(mC,3); // On rajoute des contrainte nulle sur les // N derniere variable for (INT y= mLineCC ; y<NBV ; y++) { for (INT x=0 ; x<NBV ; x++) { mtL(x,0) = (x==y); } V_GSSR_AddNewEquation(1.0,mtL.data()[0],0.0); } } for (INT x=0 ; x<NBV ; x++) { mtL(x,0) = aL[x]; } mtLC.mul(mtL,mC); mtLCE.mul(mtLC,mE); for (INT x=mLineCC ; x<NBV ; x++) mtLC(x,0)=0; V_GSSR_AddNewEquation(aPds, mtLC.data()[0],aB-mtLCE(0,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; }
void cGenSysSurResol::LVM_Mul(const tSysCho& aLambda) { for (int aKx=0 ; aKx<NbVar(); aKx++) SetElemQuad(aKx,aKx,(1+aLambda)*GetElemQuad(aKx,aKx)); }