double E2() { switch(expr[start]) { case '+':start++;return T()+E2(); case '-':start++;return -T()+E2(); default:return 0; } }
mat sift(const mat &H) { imgpyr2 blurred; imgpyr2 edges; // 1) SIFT Scale-space extrema int noctaves = 4, nscales = 5; double sigma2 = 1.6; lappyr2(blurred, edges, noctaves, nscales, sigma2); const int radius = 1; for (int i = 0; i < edges.size(); i++) { for (int j = 1; j < edges[i].size() - 1; j++) { // grab three blurred images from an octave mat E1 = edges[i][j]; mat E0 = edges[i][j - 1]; mat E2 = edges[i][j + 1]; // for every pixel in E1, check to make sure that it // is larger or smaller than all neighbors (local extrema) bool max_ext = true; bool min_ext = true; for (int u = 0; u < E1.n_rows; u++) { for (int v = 0; v < E1.n_cols; v++) { if (u == 0 || v == 0 || u == E1.n_rows || v = E1.n_cols) { E1(u, v) = 0; } // find the extrema in the images for (int x = -radius; x <= radius; x++) { for (int y = -radius; y <= radius; y++) { if (E1(u, v) < E0(u + y, v + x) || E1(u, v) < E2(u + y, v + x) || E1(u, v) < E1(u + y, v + x)) { max_ext = false; } if (E1(u, v) > E0(u + y, v + x) || E1(u, v) > E2(u + y, v + x) || E1(u, v) > E1(u + y, v + x)) { min_ext = false; } } } E1(u, v) = max_ext || min_ext; } } // once we have the image pyramids, then we can // try to find the magnitude of the keypoint descriptor } } // 2) Accurate Keypoint Localization // use the Taylor method (later on) // for now just return everything // 3) Orientation Assignment }
HRESULT CTDSThrough7ParameterPositionVector::SetModelParameters2 (double ha, double f) { m_DstSys.m_HA = ha; m_DstSys.m_f = f; m_DstSys.m_HB = HB(ha, f); m_DstSys.m_e2 = E2(f); m_DstSys.m_e12 = E12(f); m_DstSys.m_e22 = E22(ha, HB(ha, f)); return S_OK; }
static char * rw_encrypt (const dckey *key, const char *msg) { const rw_pub *pk = (const rw_pub *) key; mpz_t m; char *res = NULL; mpz_init (m); if (pre_encrypt (m, msg, pk->nbits)) { mpz_clear (m); return NULL; } E1 (m, m, pk->n); E2 (m, m, pk->n); cat_mpz (&res, m); mpz_clear (m); return res; }
bool Plane::rayIntersects(const RayTracing::Ray_t &ray, const float t0, const float t1, RayTracing::HitInfo_t &hitinfo) const { gml::vec3_t E1(0.0f, 0.0f, 2.0f); gml::vec3_t E2(2.0f, 0.0f, 0.0f); gml::vec3_t P = gml::cross( ray.d, E2 ); float detM = gml::dot(P, E1); if (fabs(detM) < 1e-4) { return false; } gml::vec3_t T = gml::sub( ray.o, _verts[0] ); float u = gml::dot( P, T ) / detM; if ( u < 0.0f || 1.0f < u ) { return false; } gml::vec3_t TxE1 = gml::cross(T, E1); float v = gml::dot( TxE1, ray.d ) / detM; if ( v < 0.0f || 1.0f < v) { return false; } float t = gml::dot( TxE1, E2 ) / detM; if (t < t0 || t1 < t) { return false; } hitinfo.hitDist = t; hitinfo.plane.u = u; hitinfo.plane.v = v; return true; }
//Spell3「交差弾」 void shot_E2(){ int t=spcount; if(t>=120){ if(t%70==0){ E2(); se_flag[0]=1; } } for(int i=0;i<BULLET_MAX;i++){//全弾分 if(bullet[i].flag>0){//登録されている弾があれば if(30<bullet[i].cnt && bullet[i].cnt<120){//30〜120カウントなら bullet[i].spd-=1.7/90.0;//90カウントかけて1.7減らす bullet[i].angle+=(PI/4)/90.0*(bullet[i].state?-1:1);//90カウントかけて45°傾ける(stateで分離) } if(bullet[i].cnt==120) bullet[i].state=3; //ダメージ減少補正 } } }
bool Plane::shadowsRay(const RayTracing::Ray_t &ray, const float t0, const float t1) const { gml::vec3_t E1(0.0f, 0.0f, 2.0f); gml::vec3_t E2(2.0f, 0.0f, 0.0f); gml::vec3_t P = gml::cross( ray.d, E2 ); float detM = gml::dot(P, E1); if (fabs(detM) < 1e-4) { return false; } gml::vec3_t T = gml::sub( ray.o, _verts[0] ); float u = gml::dot( P, T ) / detM; if ( u < 0.0f || 1.0f < u ) { return false; } gml::vec3_t TxE1 = gml::cross(T, E1); float v = gml::dot( TxE1, ray.d ) / detM; if ( v < 0.0f || 1.0f < v) { return false; } float t = gml::dot( TxE1, E2 ) / detM; if (t < t0 || t1 < t) { return false; } return true; }
static int rw_verify (const dckey *key, const char *msg, const char *sig) { const rw_pub *pk = (const rw_pub *) key; sha1_ctx sc; mpz_t m,s; int ret; mpz_init (s); mpz_init (m); if (read_mpz (&sig, s)) { mpz_clear (s); return 0; } E2 (m, s, pk->n); D1 (m, m, pk->n); sha1_init (&sc); sha1_update (&sc, msg, strlen (msg)); ret = post_verify (&sc, m, pk->nbits); mpz_clear (s); mpz_clear (m); return ret; }
int KinZfitter::PerZ1Likelihood(double & l1, double & l2, double & lph1, double & lph2) { l1= 1.0; l2 = 1.0; lph1 = 1.0; lph2 = 1.0; if(debug_) cout<<"start Z1 refit"<<endl; TLorentzVector Z1_1 = p4sZ1_[0]; TLorentzVector Z1_2 = p4sZ1_[1]; double RECOpT1 = Z1_1.Pt(); double RECOpT2 = Z1_2.Pt(); double pTerrZ1_1 = pTerrsZ1_[0]; double pTerrZ1_2 = pTerrsZ1_[1]; if(debug_)cout<<"pT1 "<<RECOpT1<<" pTerrZ1_1 "<<pTerrZ1_1<<endl; if(debug_)cout<<"pT2 "<<RECOpT2<<" pTerrZ1_2 "<<pTerrZ1_2<<endl; ////////////// TLorentzVector Z1_ph1, Z1_ph2; double pTerrZ1_ph1, pTerrZ1_ph2; double RECOpTph1, RECOpTph2; TLorentzVector nullFourVector(0, 0, 0, 0); Z1_ph1=nullFourVector; Z1_ph2=nullFourVector; RECOpTph1 = 0; RECOpTph2 = 0; pTerrZ1_ph1 = 0; pTerrZ1_ph2 = 0; if(p4sZ1ph_.size()>=1){ Z1_ph1 = p4sZ1ph_[0]; pTerrZ1_ph1 = pTerrsZ1ph_[0]; RECOpTph1 = Z1_ph1.Pt(); if(debug_) cout<<"put in Z1 fsr photon 1 pT "<<RECOpTph1<<" pT err "<<pTerrZ1_ph1<<endl; } if(p4sZ1ph_.size()==2){ //if(debug_) cout<<"put in Z1 fsr photon 2"<<endl; Z1_ph2 = p4sZ1ph_[1]; pTerrZ1_ph2 = pTerrsZ1ph_[1]; RECOpTph2 = Z1_ph2.Pt(); } RooRealVar* pT1RECO = new RooRealVar("pT1RECO","pT1RECO", RECOpT1, 5, 500); RooRealVar* pT2RECO = new RooRealVar("pT2RECO","pT2RECO", RECOpT2, 5, 500); double RECOpT1min = max(5.0, RECOpT1-2*pTerrZ1_1); double RECOpT2min = max(5.0, RECOpT2-2*pTerrZ1_2); RooRealVar* pTph1RECO = new RooRealVar("pTph1RECO","pTph1RECO", RECOpTph1, 5, 500); RooRealVar* pTph2RECO = new RooRealVar("pTph2RECO","pTph2RECO", RECOpTph2, 5, 500); double RECOpTph1min = max(0.5, RECOpTph1-2*pTerrZ1_ph1); double RECOpTph2min = max(0.5, RECOpTph2-2*pTerrZ1_ph2); // observables pT1,2,ph1,ph2 RooRealVar* pT1 = new RooRealVar("pT1", "pT1FIT", RECOpT1, RECOpT1min, RECOpT1+2*pTerrZ1_1 ); RooRealVar* pT2 = new RooRealVar("pT2", "pT2FIT", RECOpT2, RECOpT2min, RECOpT2+2*pTerrZ1_2 ); RooRealVar* m1 = new RooRealVar("m1","m1", Z1_1.M()); RooRealVar* m2 = new RooRealVar("m2","m2", Z1_2.M()); if(debug_) cout<<"m1 "<<m1->getVal()<<" m2 "<<m2->getVal()<<endl; double Vtheta1, Vphi1, Vtheta2, Vphi2; Vtheta1 = (Z1_1).Theta(); Vtheta2 = (Z1_2).Theta(); Vphi1 = (Z1_1).Phi(); Vphi2 = (Z1_2).Phi(); RooRealVar* theta1 = new RooRealVar("theta1","theta1",Vtheta1); RooRealVar* phi1 = new RooRealVar("phi1","phi1",Vphi1); RooRealVar* theta2 = new RooRealVar("theta2","theta2",Vtheta2); RooRealVar* phi2 = new RooRealVar("phi2","phi2",Vphi2); // dot product to calculate (p1+p2+ph1+ph2).M() RooFormulaVar E1("E1","TMath::Sqrt((@0*@0)/((TMath::Sin(@1))*(TMath::Sin(@1)))+@2*@2)", RooArgList(*pT1,*theta1,*m1)); RooFormulaVar E2("E2","TMath::Sqrt((@0*@0)/((TMath::Sin(@1))*(TMath::Sin(@1)))+@2*@2)", RooArgList(*pT2,*theta2,*m2)); if(debug_) cout<<"E1 "<<E1.getVal()<<"; E2 "<<E2.getVal()<<endl; ///// RooRealVar* pTph1 = new RooRealVar("pTph1", "pTph1FIT", RECOpTph1, RECOpTph1min, RECOpTph1+2*pTerrZ1_ph1 ); RooRealVar* pTph2 = new RooRealVar("pTph2", "pTph2FIT", RECOpTph2, RECOpTph2min, RECOpTph2+2*pTerrZ1_ph2 ); double Vthetaph1, Vphiph1, Vthetaph2, Vphiph2; Vthetaph1 = (Z1_ph1).Theta(); Vthetaph2 = (Z1_ph2).Theta(); Vphiph1 = (Z1_ph1).Phi(); Vphiph2 = (Z1_ph2).Phi(); RooRealVar* thetaph1 = new RooRealVar("thetaph1","thetaph1",Vthetaph1); RooRealVar* phiph1 = new RooRealVar("phiph1","phiph1",Vphiph1); RooRealVar* thetaph2 = new RooRealVar("thetaph2","thetaph2",Vthetaph2); RooRealVar* phiph2 = new RooRealVar("phiph2","phi2",Vphiph2); RooFormulaVar Eph1("Eph1","TMath::Sqrt((@0*@0)/((TMath::Sin(@1))*(TMath::Sin(@1))))", RooArgList(*pTph1,*thetaph1)); RooFormulaVar Eph2("Eph2","TMath::Sqrt((@0*@0)/((TMath::Sin(@1))*(TMath::Sin(@1))))", RooArgList(*pTph2,*thetaph2)); //// dot products of 4-vectors // 3-vector DOT RooFormulaVar* p1v3D2 = new RooFormulaVar("p1v3D2", "@0*@1*( ((TMath::Cos(@2))*(TMath::Cos(@3)))/((TMath::Sin(@2))*(TMath::Sin(@3)))+(TMath::Cos(@4-@5)))", RooArgList(*pT1,*pT2,*theta1,*theta2,*phi1,*phi2)); if(debug_) cout<<"p1 DOT p2 is "<<p1v3D2->getVal()<<endl; // 4-vector DOT metric 1 -1 -1 -1 RooFormulaVar p1D2("p1D2","@0*@1-@2",RooArgList(E1,E2,*p1v3D2)); //lep DOT fsrPhoton1 // 3-vector DOT RooFormulaVar* p1v3Dph1 = new RooFormulaVar("p1v3Dph1", "@0*@1*( (TMath::Cos(@2)*TMath::Cos(@3))/(TMath::Sin(@2)*TMath::Sin(@3))+TMath::Cos(@4-@5))", RooArgList(*pT1,*pTph1,*theta1,*thetaph1,*phi1,*phiph1)); // 4-vector DOT metric 1 -1 -1 -1 RooFormulaVar p1Dph1("p1Dph1","@0*@1-@2",RooArgList(E1,Eph1,*p1v3Dph1)); // 3-vector DOT RooFormulaVar* p2v3Dph1 = new RooFormulaVar("p2v3Dph1", "@0*@1*( (TMath::Cos(@2)*TMath::Cos(@3))/(TMath::Sin(@2)*TMath::Sin(@3))+TMath::Cos(@4-@5))", RooArgList(*pT2,*pTph1,*theta2,*thetaph1,*phi2,*phiph1)); // 4-vector DOT metric 1 -1 -1 -1 RooFormulaVar p2Dph1("p2Dph1","@0*@1-@2",RooArgList(E2,Eph1,*p2v3Dph1)); // lep DOT fsrPhoton2 // 3-vector DOT RooFormulaVar* p1v3Dph2 = new RooFormulaVar("p1v3Dph2", "@0*@1*( (TMath::Cos(@2)*TMath::Cos(@3))/(TMath::Sin(@2)*TMath::Sin(@3))+TMath::Cos(@4-@5))", RooArgList(*pT1,*pTph2,*theta1,*thetaph2,*phi1,*phiph2)); // 4-vector DOT metric 1 -1 -1 -1 RooFormulaVar p1Dph2("p1Dph2","@0*@1-@2",RooArgList(E1,Eph2,*p1v3Dph2)); // 3-vector DOT RooFormulaVar* p2v3Dph2 = new RooFormulaVar("p2v3Dph2", "@0*@1*( (TMath::Cos(@2)*TMath::Cos(@3))/(TMath::Sin(@2)*TMath::Sin(@3))+TMath::Cos(@4-@5))", RooArgList(*pT2,*pTph2,*theta2,*thetaph2,*phi2,*phiph2)); // 4-vector DOT metric 1 -1 -1 -1 RooFormulaVar p2Dph2("p2Dph2","@0*@1-@2",RooArgList(E2,Eph2,*p2v3Dph2)); // fsrPhoton1 DOT fsrPhoton2 // 3-vector DOT RooFormulaVar* ph1v3Dph2 = new RooFormulaVar("ph1v3Dph2", "@0*@1*( (TMath::Cos(@2)*TMath::Cos(@3))/(TMath::Sin(@2)*TMath::Sin(@3))+TMath::Cos(@4-@5))", RooArgList(*pTph1,*pTph2,*thetaph1,*thetaph2,*phiph1,*phiph2)); // 4-vector DOT metric 1 -1 -1 -1 RooFormulaVar ph1Dph2("ph1Dph2","@0*@1-@2",RooArgList(Eph1,Eph2,*ph1v3Dph2)); // mZ1 RooFormulaVar* mZ1; mZ1 = new RooFormulaVar("mZ1","TMath::Sqrt(2*@0+@1*@1+@2*@2)",RooArgList(p1D2,*m1,*m2)); if(p4sZ1ph_.size()==1) mZ1 = new RooFormulaVar("mZ1","TMath::Sqrt(2*@0+2*@1+2*@2+@3*@3+@4*@4)", RooArgList(p1D2, p1Dph1, p2Dph1, *m1,*m2)); if(p4sZ1ph_.size()==2) mZ1 = new RooFormulaVar("mZ1","TMath::Sqrt(2*@0+2*@1+2*@2+2*@3+2*@4+2*@5+@6*@6+@7*@7)", RooArgList(p1D2,p1Dph1,p2Dph1,p1Dph2,p2Dph2,ph1Dph2, *m1,*m2)); if(debug_) cout<<"mZ1 is "<<mZ1->getVal()<<endl; // pTerrs, 1,2,ph1,ph2 RooRealVar sigmaZ1_1("sigmaZ1_1", "sigmaZ1_1", pTerrZ1_1); RooRealVar sigmaZ1_2("sigmaZ1_2", "sigmaZ1_2", pTerrZ1_2); RooRealVar sigmaZ1_ph1("sigmaZ1_ph1", "sigmaZ1_ph1", pTerrZ1_ph1); RooRealVar sigmaZ1_ph2("sigmaZ1_ph2", "sigmaZ1_ph2", pTerrZ1_ph2); // resolution for decay products RooGaussian gauss1("gauss1","gaussian PDF", *pT1RECO, *pT1, sigmaZ1_1); RooGaussian gauss2("gauss2","gaussian PDF", *pT2RECO, *pT2, sigmaZ1_2); RooGaussian gaussph1("gaussph1","gaussian PDF", *pTph1RECO, *pTph1, sigmaZ1_ph1); RooGaussian gaussph2("gaussph2","gaussian PDF", *pTph2RECO, *pTph2, sigmaZ1_ph2); RooRealVar bwMean("bwMean", "m_{Z^{0}}", 91.187); RooRealVar bwGamma("bwGamma", "#Gamma", 2.5); RooRealVar sg("sg", "sg", sgVal_); RooRealVar a("a", "a", aVal_); RooRealVar n("n", "n", nVal_); RooCBShape CB("CB","CB",*mZ1,bwMean,sg,a,n); RooRealVar f("f","f", fVal_); RooRealVar mean("mean","mean",meanVal_); RooRealVar sigma("sigma","sigma",sigmaVal_); RooRealVar f1("f1","f1",f1Val_); RooGenericPdf RelBW("RelBW","1/( pow(mZ1*mZ1-bwMean*bwMean,2)+pow(mZ1,4)*pow(bwGamma/bwMean,2) )", RooArgSet(*mZ1,bwMean,bwGamma) ); RooAddPdf RelBWxCB("RelBWxCB","RelBWxCB", RelBW, CB, f); RooGaussian gauss("gauss","gauss",*mZ1,mean,sigma); RooAddPdf RelBWxCBxgauss("RelBWxCBxgauss","RelBWxCBxgauss", RelBWxCB, gauss, f1); RooProdPdf *PDFRelBWxCBxgauss; PDFRelBWxCBxgauss = new RooProdPdf("PDFRelBWxCBxgauss","PDFRelBWxCBxgauss", RooArgList(gauss1, gauss2, RelBWxCBxgauss) ); if(p4sZ1ph_.size()==1) PDFRelBWxCBxgauss = new RooProdPdf("PDFRelBWxCBxgauss","PDFRelBWxCBxgauss", RooArgList(gauss1, gauss2, gaussph1, RelBWxCBxgauss) ); if(p4sZ1ph_.size()==2) PDFRelBWxCBxgauss = new RooProdPdf("PDFRelBWxCBxgauss","PDFRelBWxCBxgauss", RooArgList(gauss1, gauss2, gaussph1, gaussph2, RelBWxCBxgauss) ); // observable set RooArgSet *rastmp; rastmp = new RooArgSet(*pT1RECO,*pT2RECO); if(p4sZ1ph_.size()==1) rastmp = new RooArgSet(*pT1RECO,*pT2RECO,*pTph1RECO); if(p4sZ1ph_.size()>=2) rastmp = new RooArgSet(*pT1RECO,*pT2RECO,*pTph1RECO,*pTph2RECO); RooDataSet* pTs = new RooDataSet("pTs","pTs", *rastmp); pTs->add(*rastmp); //RooAbsReal* nll; //nll = PDFRelBWxCBxgauss->createNLL(*pTs); //RooMinuit(*nll).migrad(); RooFitResult* r = PDFRelBWxCBxgauss->fitTo(*pTs,RooFit::Save(),RooFit::PrintLevel(-1)); const TMatrixDSym& covMatrix = r->covarianceMatrix(); const RooArgList& finalPars = r->floatParsFinal(); for (int i=0 ; i<finalPars.getSize(); i++){ TString name = TString(((RooRealVar*)finalPars.at(i))->GetName()); if(debug_) cout<<"name list of RooRealVar for covariance matrix "<<name<<endl; } int size = covMatrix.GetNcols(); //TMatrixDSym covMatrixTest_(size); covMatrixZ1_.ResizeTo(size,size); covMatrixZ1_ = covMatrix; if(debug_) cout<<"save the covariance matrix"<<endl; l1 = pT1->getVal()/RECOpT1; l2 = pT2->getVal()/RECOpT2; double pTerrZ1REFIT1 = pT1->getError(); double pTerrZ1REFIT2 = pT2->getError(); pTerrsZ1REFIT_.push_back(pTerrZ1REFIT1); pTerrsZ1REFIT_.push_back(pTerrZ1REFIT2); if(p4sZ1ph_.size()>=1){ if(debug_) cout<<"set refit result for Z1 fsr photon 1"<<endl; lph1 = pTph1->getVal()/RECOpTph1; double pTerrZ1phREFIT1 = pTph1->getError(); if(debug_) cout<<"scale "<<lph1<<" pterr "<<pTerrZ1phREFIT1<<endl; pTerrsZ1phREFIT_.push_back(pTerrZ1phREFIT1); } if(p4sZ1ph_.size()==2){ lph2 = pTph2->getVal()/RECOpTph2; double pTerrZ1phREFIT2 = pTph2->getError(); pTerrsZ1phREFIT_.push_back(pTerrZ1phREFIT2); } //delete nll; delete r; delete mZ1; delete pT1; delete pT2; delete pTph1; delete pTph2; delete pT1RECO; delete pT2RECO; delete pTph1RECO; delete pTph2RECO; delete ph1v3Dph2; delete p1v3Dph1; delete p2v3Dph1; delete p1v3Dph2; delete p2v3Dph2; delete PDFRelBWxCBxgauss; delete pTs; delete rastmp; if(debug_) cout<<"end Z1 refit"<<endl; return 0; }
size_t BadLineSegmentIntersection::calc( void *progress/*=0*/ ) { map<IntersectedPoint_Derived*,int,ComparePoint>::iterator it; double x,y; for(int i=0;i<m_lineSegs.size()-1;i++) { for(int j=i+1;j<m_lineSegs.size();j++) { int intersected = m_lineSegs[i]->Intersection2Segment(*m_lineSegs[j],x,y); //if(progress!=0) ;//progress->tick(); if(intersected==1) { IntersectedPoint_Derived* tmp=new IntersectedPoint_Derived(x,y); it=m_mapPoints.find(tmp); ///Kiểm tra điểm này có trong danh sách giao điểm chưa if(it!=m_mapPoints.end()) { ///Nếu đã tồn tại thì thêm 2 đoạn đang xét vào danh sách những đoạn đi qua điểm này it->first->AddLineToList(m_lineSegs[i]); it->first->AddLineToList(m_lineSegs[j]); delete tmp; } else { tmp->AddLineToList(m_lineSegs[i]); tmp->AddLineToList(m_lineSegs[j]); m_mapPoints.insert(pair<IntersectedPoint_Derived*,int>(tmp,0)); } } else if(intersected==-1) ///Trường hợp 2 đoạn nằm trên 1 đường thẳng nhưng có chung đầu mút { IntersectedPoint_Derived D1(m_lineSegs[i]->x1,m_lineSegs[i]->y1); IntersectedPoint_Derived D2(m_lineSegs[i]->x2,m_lineSegs[i]->y2); IntersectedPoint_Derived E1(m_lineSegs[j]->x1,m_lineSegs[j]->y1); IntersectedPoint_Derived E2(m_lineSegs[j]->x2,m_lineSegs[j]->y2); if(D1==E2 ) { IntersectedPoint_Derived *tmp=new IntersectedPoint_Derived(D1.x,D1.y); tmp->AddLineToList(m_lineSegs[i]); tmp->AddLineToList(m_lineSegs[j]); m_mapPoints.insert(pair<IntersectedPoint_Derived*,int>(tmp,0)); } if(D2==E1) { IntersectedPoint_Derived *tmp=new IntersectedPoint_Derived(D2.x,D2.y); tmp->AddLineToList(m_lineSegs[i]); tmp->AddLineToList(m_lineSegs[j]); m_mapPoints.insert(pair<IntersectedPoint_Derived*,int>(tmp,0)); } } } }; ///copy cac diem tu Map tra ve vector map<IntersectedPoint_Derived*,int,ComparePoint>::iterator it_2=m_mapPoints.begin(); while(it_2!=m_mapPoints.end()) { m_IntersectedPoints.push_back(it_2->first); it_2++; } return m_IntersectedPoints.size(); }
/// Adaptive Weights disparity computation. /// /// The dissimilarity is computed putting adaptive weights on the raw cost. /// \param im1,im2 the two color images /// \param dMin,dMax disparity range /// \param param raw cost computation parameters /// \param disp1 output disparity map from image 1 to image 2 /// \param disp2 output disparity map from image 2 to image 1 void disparityAW(Image im1, Image im2, int dMin, int dMax, const ParamDisparity& param, Image& disp1, Image& disp2) { const int width=im1.width(), height=im1.height(); const int r = param.radius; #ifdef COMB_LEFT // Disparity range const int nd = 1; // Do not compute useless weights in target image #else const int nd = dMax-dMin+1; #endif // Tabulated proximity weights (color distance) const int maxL1 = im1.channels()*255; // Maximum L1 distance between colors float* distC = new float[maxL1+1]; float e2=exp(-1/(im1.channels()*param.gammaCol)); distC[0]=1.0f; for(int x=1; x<=maxL1; x++) distC[x] = e2*distC[x-1]; // distC[x] = exp(-x/(c*gamma)) // Tabulated proximity weights (spatial distance) const int dim=2*r+1; // window dimension float *distP = new float[dim*dim], *d=distP; for(int y=-r; y<=r; y++) for(int x=-r; x<=r; x++) *d++ = exp(-2.0f*sqrt((float)(x*x+y*y))/param.gammaPos); Image* cost = costVolume(im1, im2, dMin, dMax, param); // Images of dissimilarity 1->2 and 2->1 Image E1(width,height), E2(width,height); std::fill_n(&E1(0,0), width*height, std::numeric_limits<float>::max()); std::fill_n(&E2(0,0), width*height, std::numeric_limits<float>::max()); #ifdef _OPENMP #pragma omp parallel for #endif for(int y=0; y<height; y++) { // Weight window in reference image Image W1(dim,dim); // Weight windows in target image for each disparity (useless for // COMB_LEFT, but better to have readable code than multiplying #ifdef) Image* weights2 = new Image[nd]; for(int d=0; d<nd; d++) { weights2[d] = Image(dim,dim); if(d+1<nd) // Support for dMax computed later support(im2, d,y, r, distC, weights2[d]); } for(int x=0; x<width; x++) { // Reference window weights support(im1, x,y, r, distC, W1); #ifndef COMB_LEFT // Weight window at disparity dMax in target image support(im2, x+dMax,y, r, distC, weights2[(x+dMax-dMin)%nd]); #endif for(int d=dMin; d<=dMax; d++) { if(0<=x+d && x+d<width) { const Image& e = cost[d-dMin]; // Raw cost for disp. d const Image& W2 = weights2[(x+d-dMin)%nd]; float E = costCombined(x, x+d, y, r, W1, W2, distP, e); if(E1(x,y) > E) { E1(x,y) = E; disp1(x,y) = static_cast<float>(d); } if(E2(x+d,y) > E) { E2(x+d,y) = E; disp2(x+d,y)= -static_cast<float>(d); } } } } delete [] weights2; } delete [] cost; delete [] distC; delete [] distP; }
void TJerFile::GetDiffFile(const char *ASrcDir,const char *ADestDir,BList *Diff) { //----------------------------------------- // We are looking for files not found in Dest... //----------------------------------------- BList ASrcList; BList ADestList; char name1[B_FILE_NAME_LENGTH]; char name2[B_FILE_NAME_LENGTH]; off_t Size1; off_t Size2; int32 CRC1,CRC2; BPath P1; BPath P2; char *RelativePath1; char *RelativePath2; bool EntryFound = false; entry_ref *buf_entry,*buf_entry2,*copy_entry; BMessage *AMessage; BFile *file2; BFile *file1; GetAllFile(ASrcDir,&ASrcList); GetAllFile(ADestDir,&ADestList); AMessage = new BMessage(B_RESET_STATUS_BAR); AMessage->AddFloat("maximum",ASrcList.CountItems()); MyInvoker.Invoke(AMessage); delete AMessage; for (int ind=0;ind < ASrcList.CountItems();ind++ ) { buf_entry = (entry_ref *)(ASrcList.ItemAt(ind)); if (buf_entry!=NULL) { BEntry E1(buf_entry); E1.GetName(name1); E1.GetPath(&P1); GetRelativePath(ASrcDir,P1.Path(),&RelativePath1); file1 = new BFile(buf_entry,B_READ_ONLY); // printf("Checking file ....%s \n",P1.Path()); // The Message is put here to update when the link files are found too. AMessage = new BMessage(B_UPDATE_STATUS_BAR); AMessage->AddFloat("delta",1.0); AMessage->AddString("text","Checking..."); AMessage->AddString("trailingtext",P1.Path()); MyInvoker.Invoke(AMessage); delete AMessage; if (file1->InitCheck()==B_NO_ERROR) //Because of linkfiles.... { try { file1->GetSize(&Size1); if (CalculateCRC==true) { printf("CRC Calculation First File...\n"); CRC1 = CRCFile(file1); } // printf("Checking file ....%s Size: %d CRC: %d \n",P1.Path(),Size1,CRC1); EntryFound = false; } catch(GeneralException &e) { delete file1; printf("Exception in File1..."); throw; } delete file1; for (int ind2=0;ind2 < ADestList.CountItems();ind2++ ) { buf_entry2 = (entry_ref *)(ADestList.ItemAt(ind2)); if (buf_entry2!=NULL) { BEntry E2(buf_entry2); E2.GetName(name2); E2.GetPath(&P2); GetRelativePath(ADestDir,P2.Path(),&RelativePath2); if ((strcmp(name1,name2)==0) && (strcmp(RelativePath1,RelativePath2)==0)) { // printf("name1 : %s, name2 : %s \n",name1,name2); // printf("RP1 : %s, RP2 : %s \n",RelativePath1,RelativePath2); // printf("PAth1 : %s, Path2 : %s \n",P1.Path(),P2.Path()); file2 = new BFile(buf_entry2,B_READ_ONLY); file2->GetSize(&Size2); // printf("Size2 %d\n",Size2); if (Size1==Size2) { //CRC Test try { if (CalculateCRC==true) { printf("CRC Calculation Second File...\n"); CRC2 = CRCFile(file2); if (CRC1==CRC2) { EntryFound = true; delete file2; break; //Data found... } } } catch(GeneralException &e) { printf("Error in GetDiffFile %s\n",P2.Path()); throw; } } delete file2; } } } if (EntryFound==false) { copy_entry = new entry_ref; *copy_entry = *buf_entry; Diff->AddItem(copy_entry); /* BMessage AMessage(GET_FILES); AMessage.AddRef("ref",copy_entry); int result = MyInvoker.Invoke(&AMessage); if (result!= B_OK) { if (result == B_BAD_PORT_ID) { ShowMessage("Bad Port"); } else if (result == B_TIMED_OUT) { ShowMessage("TIMED_OUT"); } else ShowMessage("Other Error"); } */ } } // End of InitCheck } } // Just to let the main loop that we have finished checking... for the moment we only // use it to test if the OutLineList is void.... /* BMessage AMessage2(END_CHECKING); int result2 = MyInvoker.Invoke(&AMessage2); if (result2!= B_OK) { if (result2 == B_BAD_PORT_ID) { ShowMessage("Bad Port"); } else if (result2 == B_TIMED_OUT) { ShowMessage("TIMED_OUT"); } else ShowMessage("Other Error"); } */ }
DOUBLE check_tilt_pairs(DOUBLE rot1, DOUBLE tilt1, DOUBLE psi1, DOUBLE &alpha, DOUBLE &tilt_angle, DOUBLE &beta) { // Transformation matrices Matrix1D<DOUBLE> axis(3); Matrix2D<DOUBLE> E1, E2; axis.resize(3); DOUBLE aux, sine_tilt_angle; DOUBLE rot2 = alpha, tilt2 = tilt_angle, psi2 = beta; // Calculate the transformation from one setting to the second one. Euler_angles2matrix(psi1, tilt1, rot1, E1); Euler_angles2matrix(psi2, tilt2, rot2, E2); E2 = E2 * E1.inv(); // Get the tilt angle (and its sine) aux = ( E2(0,0) + E2(1,1) + E2(2,2) - 1. ) / 2.; if (ABS(aux) - 1. > XMIPP_EQUAL_ACCURACY) REPORT_ERROR("BUG: aux>1"); tilt_angle = ACOSD(aux); sine_tilt_angle = 2. * SIND(tilt_angle); // Get the tilt axis direction in angles alpha and beta if (sine_tilt_angle > XMIPP_EQUAL_ACCURACY) { axis(0) = ( E2(2,1) - E2(1,2) ) / sine_tilt_angle; axis(1) = ( E2(0,2) - E2(2,0) ) / sine_tilt_angle; axis(2) = ( E2(1,0) - E2(0,1) ) / sine_tilt_angle; } else { axis(0) = axis(1) = 0.; axis(2) = 1.; } // Apply E1.inv() to the axis to get everyone in the same coordinate system again axis = E1.inv() * axis; // Convert to alpha and beta angle Euler_direction2angles(axis, alpha, beta); // Enforce positive beta: choose the other Euler angle combination to express the same direction if (beta < 0.) { beta = -beta; alpha+= 180.; } // Let alpha go from 0 to 360 degrees alpha = realWRAP(alpha, 0., 360.); // Return the value that needs to be optimized DOUBLE minimizer=0.; if (exp_beta < 999.) minimizer = ABS(beta - exp_beta); if (exp_tilt < 999.) minimizer += ABS(tilt_angle - exp_tilt); return minimizer; }
/* Subroutine */ int slaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, integer *minp, integer *nbmin, real *abstol, real * reltol, real *pivmin, real *d, real *e, real *e2, integer *nval, real *ab, real *c, integer *mout, integer *nab, real *work, integer *iwork, integer *info) { /* -- LAPACK auxiliary routine (version 2.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University September 30, 1994 Purpose ======= SLAEBZ contains the iteration loops which compute and use the function N(w), which is the count of eigenvalues of a symmetric tridiagonal matrix T less than or equal to its argument w. It performs a choice of two types of loops: IJOB=1, followed by IJOB=2: It takes as input a list of intervals and returns a list of sufficiently small intervals whose union contains the same eigenvalues as the union of the original intervals. The input intervals are (AB(j,1),AB(j,2)], j=1,...,MINP. The output interval (AB(j,1),AB(j,2)] will contain eigenvalues NAB(j,1)+1,...,NAB(j,2), where 1 <= j <= MOUT. IJOB=3: It performs a binary search in each input interval (AB(j,1),AB(j,2)] for a point w(j) such that N(w(j))=NVAL(j), and uses C(j) as the starting point of the search. If such a w(j) is found, then on output AB(j,1)=AB(j,2)=w. If no such w(j) is found, then on output (AB(j,1),AB(j,2)] will be a small interval containing the point where N(w) jumps through NVAL(j), unless that point lies outside the initial interval. Note that the intervals are in all cases half-open intervals, i.e., of the form (a,b] , which includes b but not a . To avoid underflow, the matrix should be scaled so that its largest element is no greater than overflow**(1/2) * underflow**(1/4) in absolute value. To assure the most accurate computation of small eigenvalues, the matrix should be scaled to be not much smaller than that, either. See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal VISMatrix", Report CS41, Computer Science Dept., Stanford University, July 21, 1966 Note: the arguments are, in general, *not* checked for unreasonable values. Arguments ========= IJOB (input) INTEGER Specifies what is to be done: = 1: Compute NAB for the initial intervals. = 2: Perform bisection iteration to find eigenvalues of T. = 3: Perform bisection iteration to invert N(w), i.e., to find a point which has a specified number of eigenvalues of T to its left. Other values will cause SLAEBZ to return with INFO=-1. NITMAX (input) INTEGER The maximum number of "levels" of bisection to be performed, i.e., an interval of width W will not be made smaller than 2^(-NITMAX) * W. If not all intervals have converged after NITMAX iterations, then INFO is set to the number of non-converged intervals. N (input) INTEGER The dimension n of the tridiagonal matrix T. It must be at least 1. MMAX (input) INTEGER The maximum number of intervals. If more than MMAX intervals are generated, then SLAEBZ will quit with INFO=MMAX+1. MINP (input) INTEGER The initial number of intervals. It may not be greater than MMAX. NBMIN (input) INTEGER The smallest number of intervals that should be processed using a vector loop. If zero, then only the scalar loop will be used. ABSTOL (input) REAL The minimum (absolute) width of an interval. When an interval is narrower than ABSTOL, or than RELTOL times the larger (in magnitude) endpoint, then it is considered to be sufficiently small, i.e., converged. This must be at least zero. RELTOL (input) REAL The minimum relative width of an interval. When an interval is narrower than ABSTOL, or than RELTOL times the larger (in magnitude) endpoint, then it is considered to be sufficiently small, i.e., converged. Note: this should always be at least radix*machine epsilon. PIVMIN (input) REAL The minimum absolute value of a "pivot" in the Sturm sequence loop. This *must* be at least max |e(j)**2| * safe_min and at least safe_min, where safe_min is at least the smallest number that can divide one without overflow. D (input) REAL array, dimension (N) The diagonal elements of the tridiagonal matrix T. E (input) REAL array, dimension (N) The offdiagonal elements of the tridiagonal matrix T in positions 1 through N-1. E(N) is arbitrary. E2 (input) REAL array, dimension (N) The squares of the offdiagonal elements of the tridiagonal matrix T. E2(N) is ignored. NVAL (input/output) INTEGER array, dimension (MINP) If IJOB=1 or 2, not referenced. If IJOB=3, the desired values of N(w). The elements of NVAL will be reordered to correspond with the intervals in AB. Thus, NVAL(j) on output will not, in general be the same as NVAL(j) on input, but it will correspond with the interval (AB(j,1),AB(j,2)] on output. AB (input/output) REAL array, dimension (MMAX,2) The endpoints of the intervals. AB(j,1) is a(j), the left endpoint of the j-th interval, and AB(j,2) is b(j), the right endpoint of the j-th interval. The input intervals will, in general, be modified, split, and reordered by the calculation. C (input/output) REAL array, dimension (MMAX) If IJOB=1, ignored. If IJOB=2, workspace. If IJOB=3, then on input C(j) should be initialized to the first search point in the binary search. MOUT (output) INTEGER If IJOB=1, the number of eigenvalues in the intervals. If IJOB=2 or 3, the number of intervals output. If IJOB=3, MOUT will equal MINP. NAB (input/output) INTEGER array, dimension (MMAX,2) If IJOB=1, then on output NAB(i,j) will be set to N(AB(i,j)). If IJOB=2, then on input, NAB(i,j) should be set. It must satisfy the condition: N(AB(i,1)) <= NAB(i,1) <= NAB(i,2) <= N(AB(i,2)), which means that in interval i only eigenvalues NAB(i,1)+1,...,NAB(i,2) will be considered. Usually, NAB(i,j)=N(AB(i,j)), from a previous call to SLAEBZ with IJOB=1. On output, NAB(i,j) will contain max(na(k),min(nb(k),N(AB(i,j)))), where k is the index of the input interval that the output interval (AB(j,1),AB(j,2)] came from, and na(k) and nb(k) are the the input values of NAB(k,1) and NAB(k,2). If IJOB=3, then on output, NAB(i,j) contains N(AB(i,j)), unless N(w) > NVAL(i) for all search points w , in which case NAB(i,1) will not be modified, i.e., the output value will be the same as the input value (modulo reorderings -- see NVAL and AB), or unless N(w) < NVAL(i) for all search points w , in which case NAB(i,2) will not be modified. Normally, NAB should be set to some distinctive value(s) before SLAEBZ is called. WORK (workspace) REAL array, dimension (MMAX) Workspace. IWORK (workspace) INTEGER array, dimension (MMAX) Workspace. INFO (output) INTEGER = 0: All intervals converged. = 1--MMAX: The last INFO intervals did not converge. = MMAX+1: More than MMAX intervals were generated. Further Details =============== This routine is intended to be called only by other LAPACK routines, thus the interface is less user-friendly. It is intended for two purposes: (a) finding eigenvalues. In this case, SLAEBZ should have one or more initial intervals set up in AB, and SLAEBZ should be called with IJOB=1. This sets up NAB, and also counts the eigenvalues. Intervals with no eigenvalues would usually be thrown out at this point. Also, if not all the eigenvalues in an interval i are desired, NAB(i,1) can be increased or NAB(i,2) decreased. For example, set NAB(i,1)=NAB(i,2)-1 to get the largest eigenvalue. SLAEBZ is then called with IJOB=2 and MMAX no smaller than the value of MOUT returned by the call with IJOB=1. After this (IJOB=2) call, eigenvalues NAB(i,1)+1 through NAB(i,2) are approximately AB(i,1) (or AB(i,2)) to the tolerance specified by ABSTOL and RELTOL. (b) finding an interval (a',b'] containing eigenvalues w(f),...,w(l). In this case, start with a Gershgorin interval (a,b). Set up AB to contain 2 search intervals, both initially (a,b). One NVAL element should contain f-1 and the other should contain l , while C should contain a and b, resp. NAB(i,1) should be -1 and NAB(i,2) should be N+1, to flag an error if the desired interval does not lie in (a,b). SLAEBZ is then called with IJOB=3. On exit, if w(f-1) < w(f), then one of the intervals -- j -- will have AB(j,1)=AB(j,2) and NAB(j,1)=NAB(j,2)=f-1, while if, to the specified tolerance, w(f-k)=...=w(f+r), k > 0 and r >= 0, then the interval will have N(AB(j,1))=NAB(j,1)=f-k and N(AB(j,2))=NAB(j,2)=f+r. The cases w(l) < w(l+1) and w(l-r)=...=w(l+k) are handled similarly. ===================================================================== Check for Errors Parameter adjustments Function Body */ /* System generated locals */ integer nab_dim1, nab_offset, ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6; real r__1, r__2, r__3, r__4; /* Local variables */ static integer itmp1, itmp2, j, kfnew, klnew, kf, ji, kl, jp, jit; static real tmp1, tmp2; #define D(I) d[(I)-1] #define E(I) e[(I)-1] #define E2(I) e2[(I)-1] #define NVAL(I) nval[(I)-1] #define C(I) c[(I)-1] #define WORK(I) work[(I)-1] #define IWORK(I) iwork[(I)-1] #define NAB(I,J) nab[(I)-1 + ((J)-1)* ( *mmax)] #define AB(I,J) ab[(I)-1 + ((J)-1)* ( *mmax)] *info = 0; if (*ijob < 1 || *ijob > 3) { *info = -1; return 0; } /* Initialize NAB */ if (*ijob == 1) { /* Compute the number of eigenvalues in the initial intervals. */ *mout = 0; i__1 = *minp; for (ji = 1; ji <= *minp; ++ji) { for (jp = 1; jp <= 2; ++jp) { tmp1 = D(1) - AB(ji,jp); if (dabs(tmp1) < *pivmin) { tmp1 = -(doublereal)(*pivmin); } NAB(ji,jp) = 0; if (tmp1 <= 0.f) { NAB(ji,jp) = 1; } i__2 = *n; for (j = 2; j <= *n; ++j) { tmp1 = D(j) - E2(j - 1) / tmp1 - AB(ji,jp); if (dabs(tmp1) < *pivmin) { tmp1 = -(doublereal)(*pivmin); } if (tmp1 <= 0.f) { ++NAB(ji,jp); } /* L10: */ } /* L20: */ } *mout = *mout + NAB(ji,2) - NAB(ji,1); /* L30: */ } return 0; } /* Initialize for loop KF and KL have the following meaning: Intervals 1,...,KF-1 have converged. Intervals KF,...,KL still need to be refined. */ kf = 1; kl = *minp; /* If IJOB=2, initialize C. If IJOB=3, use the user-supplied starting point. */ if (*ijob == 2) { i__1 = *minp; for (ji = 1; ji <= *minp; ++ji) { C(ji) = (AB(ji,1) + AB(ji,2)) * .5f; /* L40: */ } } /* Iteration loop */ i__1 = *nitmax; for (jit = 1; jit <= *nitmax; ++jit) { /* Loop over intervals */ if (kl - kf + 1 >= *nbmin && *nbmin > 0) { /* Begin of Parallel Version of the loop */ i__2 = kl; for (ji = kf; ji <= kl; ++ji) { /* Compute N(c), the number of eigenvalues less t han c */ WORK(ji) = D(1) - C(ji); IWORK(ji) = 0; if (WORK(ji) <= *pivmin) { IWORK(ji) = 1; /* Computing MIN */ r__1 = WORK(ji), r__2 = -(doublereal)(*pivmin); WORK(ji) = dmin(r__1,r__2); } i__3 = *n; for (j = 2; j <= *n; ++j) { WORK(ji) = D(j) - E2(j - 1) / WORK(ji) - C(ji); if (WORK(ji) <= *pivmin) { ++IWORK(ji); /* Computing MIN */ r__1 = WORK(ji), r__2 = -(doublereal)(*pivmin); WORK(ji) = dmin(r__1,r__2); } /* L50: */ } /* L60: */ } if (*ijob <= 2) { /* IJOB=2: Choose all intervals containing eigenv alues. */ klnew = kl; i__2 = kl; for (ji = kf; ji <= kl; ++ji) { /* Insure that N(w) is monotone Computing MIN Computing MAX */ i__5 = NAB(ji,1), i__6 = IWORK(ji); i__3 = NAB(ji,2), i__4 = max(i__5,i__6); IWORK(ji) = min(i__3,i__4); /* Update the Queue -- add intervals if bo th halves contain eigenvalues. */ if (IWORK(ji) == NAB(ji,2)) { /* No eigenvalue in the upper inter val: just use the lower interval. */ AB(ji,2) = C(ji); } else if (IWORK(ji) == NAB(ji,1)) { /* No eigenvalue in the lower inter val: just use the upper interval. */ AB(ji,1) = C(ji); } else { ++klnew; if (klnew <= *mmax) { /* Eigenvalue in both interv als -- add upper to queue. */ AB(klnew,2) = AB(ji,2); NAB(klnew,2) = NAB(ji,2); AB(klnew,1) = C(ji); NAB(klnew,1) = IWORK(ji); AB(ji,2) = C(ji); NAB(ji,2) = IWORK(ji); } else { *info = *mmax + 1; } } /* L70: */ } if (*info != 0) { return 0; } kl = klnew; } else { /* IJOB=3: Binary search. Keep only the interval containing w s.t. N(w) = NVAL */ i__2 = kl; for (ji = kf; ji <= kl; ++ji) { if (IWORK(ji) <= NVAL(ji)) { AB(ji,1) = C(ji); NAB(ji,1) = IWORK(ji); } if (IWORK(ji) >= NVAL(ji)) { AB(ji,2) = C(ji); NAB(ji,2) = IWORK(ji); } /* L80: */ } } } else { /* End of Parallel Version of the loop Begin of Serial Version of the loop */ klnew = kl; i__2 = kl; for (ji = kf; ji <= kl; ++ji) { /* Compute N(w), the number of eigenvalues less t han w */ tmp1 = C(ji); tmp2 = D(1) - tmp1; itmp1 = 0; if (tmp2 <= *pivmin) { itmp1 = 1; /* Computing MIN */ r__1 = tmp2, r__2 = -(doublereal)(*pivmin); tmp2 = dmin(r__1,r__2); } /* A series of compiler directives to defeat vect orization for the next loop $PL$ CMCHAR=' ' DIR$ NEXTSCALAR $DIR SCALAR DIR$ NEXT SCALAR VD$L NOVECTOR DEC$ NOVECTOR VD$ NOVECTOR VDIR NOVECTOR VOCL LOOP,SCALAR IBM PREFER SCALAR $PL$ CMCHAR='*' */ i__3 = *n; for (j = 2; j <= *n; ++j) { tmp2 = D(j) - E2(j - 1) / tmp2 - tmp1; if (tmp2 <= *pivmin) { ++itmp1; /* Computing MIN */ r__1 = tmp2, r__2 = -(doublereal)(*pivmin); tmp2 = dmin(r__1,r__2); } /* L90: */ } if (*ijob <= 2) { /* IJOB=2: Choose all intervals containing eigenvalues. Insure that N(w) is monotone Computing MIN Computing MAX */ i__5 = NAB(ji,1); i__3 = NAB(ji,2), i__4 = max(i__5,itmp1); itmp1 = min(i__3,i__4); /* Update the Queue -- add intervals if bo th halves contain eigenvalues. */ if (itmp1 == NAB(ji,2)) { /* No eigenvalue in the upper inter val: just use the lower interval. */ AB(ji,2) = tmp1; } else if (itmp1 == NAB(ji,1)) { /* No eigenvalue in the lower inter val: just use the upper interval. */ AB(ji,1) = tmp1; } else if (klnew < *mmax) { /* Eigenvalue in both intervals -- add upper to queue. */ ++klnew; AB(klnew,2) = AB(ji,2); NAB(klnew,2) = NAB(ji,2); AB(klnew,1) = tmp1; NAB(klnew,1) = itmp1; AB(ji,2) = tmp1; NAB(ji,2) = itmp1; } else { *info = *mmax + 1; return 0; } } else { /* IJOB=3: Binary search. Keep only the i nterval containing w s.t. N(w) = NVAL */ if (itmp1 <= NVAL(ji)) { AB(ji,1) = tmp1; NAB(ji,1) = itmp1; } if (itmp1 >= NVAL(ji)) { AB(ji,2) = tmp1; NAB(ji,2) = itmp1; } } /* L100: */ } kl = klnew; /* End of Serial Version of the loop */ } /* Check for convergence */ kfnew = kf; i__2 = kl; for (ji = kf; ji <= kl; ++ji) { tmp1 = (r__1 = AB(ji,2) - AB(ji,1), dabs( r__1)); /* Computing MAX */ r__3 = (r__1 = AB(ji,2), dabs(r__1)), r__4 = (r__2 = AB(ji,1), dabs(r__2)); tmp2 = dmax(r__3,r__4); /* Computing MAX */ r__1 = max(*abstol,*pivmin), r__2 = *reltol * tmp2; if (tmp1 < dmax(r__1,r__2) || NAB(ji,1) >= NAB(ji,2)) { /* Converged -- Swap with position KFNEW, then increment KFNEW */ if (ji > kfnew) { tmp1 = AB(ji,1); tmp2 = AB(ji,2); itmp1 = NAB(ji,1); itmp2 = NAB(ji,2); AB(ji,1) = AB(kfnew,1); AB(ji,2) = AB(kfnew,2); NAB(ji,1) = NAB(kfnew,1); NAB(ji,2) = NAB(kfnew,2); AB(kfnew,1) = tmp1; AB(kfnew,2) = tmp2; NAB(kfnew,1) = itmp1; NAB(kfnew,2) = itmp2; if (*ijob == 3) { itmp1 = NVAL(ji); NVAL(ji) = NVAL(kfnew); NVAL(kfnew) = itmp1; } } ++kfnew; } /* L110: */ } kf = kfnew; /* Choose Midpoints */ i__2 = kl; for (ji = kf; ji <= kl; ++ji) { C(ji) = (AB(ji,1) + AB(ji,2)) * .5f; /* L120: */ } /* If no more intervals to refine, quit. */ if (kf > kl) { goto L140; } /* L130: */ } /* Converged */ L140: /* Computing MAX */ i__1 = kl + 1 - kf; *info = max(i__1,0); *mout = kl; return 0; /* End of SLAEBZ */ } /* slaebz_ */
double E() { return T()+E2(); }