?? precgls.cc
字號:
//============================================================// COOOL version 1.1 --- Nov, 1995// Center for Wave Phenomena, Colorado School of Mines//============================================================//// This code is part of a preliminary release of COOOL (CWP// Object-Oriented Optimization Library) and associated class // libraries. //// The COOOL library is a free software. You can do anything you want// with it including make a fortune. However, neither the authors,// the Center for Wave Phenomena, nor anyone else you can think of// makes any guarantees about anything in this package or any aspect// of its functionality.//// Since you've got the source code you can also modify the// library to suit your own purposes. We would appreciate it // if the headers that identify the authors are kept in the // source code.////=============================// author: H. Lydia Deng, 03/14/94// derived class from CGLS, the preconditioned CGLS//=============================#include <PreCGLS.hh>PreconditionedCGLS::PreconditionedCGLS(int n, LinearForward* p, Vector<double>* data, int it, double eps): LSConjugateGradient(n, p,data,it,eps){ int size = p->dataSize(); weight = new DiagMatrix<double>(size);}PreconditionedCGLS::PreconditionedCGLS(int n, LinearForward* p, Vector<double>* data, int it, double eps, int verb): LSConjugateGradient(n, p,data,it,eps,verb){ int size = p->dataSize(); weight = new DiagMatrix<double>(size);}PreconditionedCGLS::~PreconditionedCGLS() { delete weight;} // Preconditioned Least square Conjugate gradient methodModel<double> PreconditionedCGLS::optimizer(Model<double>& model){ dataError[0] = ((MisFitFcn*)fp)->updateError(model); Vector<double> temp(dataError->size()); temp = dataError[0]*weight[0]; LSConjugateGradient::getModelError(temp); search[0] = modelError[0]; double value = fp->performance(model); if (isVerbose) cerr << "the current residue: "<< value << endl; QuadraticOptima::appendResidue(value); while(fp->iterations() < iterMax && residue->last() >tol) { LSConjugateGradient::upDating(); temp = weight[0]*dataError[0]; LSConjugateGradient::getModelError(temp); model = model.update(1,alpha,search[0]); LSConjugateGradient::conjugateDirection(); value = fp->performance(model); if (isVerbose) cerr << "the current residue: "<< value << endl; Optima::appendResidue(value); } return(model);}Model<long> PreconditionedCGLS::optimizer(Model<long>& model){ Model<double> mtemp(model); mtemp = optimizer(mtemp); Model<long> optm(mtemp); return optm;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -