ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/NLModel1.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/NLModel1.cpp (file contents):
Revision 1000 by tim, Fri Jan 30 21:47:22 2004 UTC vs.
Revision 1023 by tim, Wed Feb 4 22:26:00 2004 UTC

# Line 1 | Line 1
1   #include "NLModel.hpp"
2 + #include "Utility.hpp"
3 +
4 +
5 +
6   //calculate hessian using finite difference
7   SymMatrix NLModel1::FiniteHessian(vector<double>& x, vector<double>& h){
8  
# Line 25 | Line 29 | SymMatrix NLModel1::FiniteHessian(vector<double>& x, v
29  
30      gplus = calcGrad(tempX);
31  
32 <    hessian.Cloume(i) = (gplus - currentGrad) / hi;  
32 >    //hessian.Colume(i) = (gplus - currentGrad) / hi;  
33  
34      //restore tempX to its original value
35      tempX[i] -= hi;
# Line 63 | Line 67 | double ConcreteNLMode1::calcF(){
67    
68   }
69  
70 < double ConcreteNLMode1::calcF(){
70 > //----------------------------------------------------------------------------//
71 > ConcreteNLModel1::ConcreteNLModel1(int dim, ObjFunctor1* func ,  ConstraintList* cons)
72 >                         : NLModel1(dim, cons){
73 >  objfunc = func;
74 > }
75 > double ConcreteNLModel1::calcF(){
76    
77    currentF = (*objfunc)(currentX, currentGrad);
78 <  numOfProc++;
78 >  numOfFunEval ++;
79  
80 <  return curretF;
80 >  return currentF;
81   }
82  
83 < double ConcreteNLMode1::calcF(const vector<double>& x){
83 > double ConcreteNLModel1::calcF(vector<double>& x){
84  
85    vector<double> tempGrad(x.size());
86    
# Line 83 | Line 92 | vector<double> ConcreteNLMode1::calcGrad(){
92    return tempF;  
93   }
94  
95 < vector<double> ConcreteNLMode1::calcGrad(){
96 <
95 > vector<double> ConcreteNLModel1::calcGrad(){
96 >  
97    currentF = (*objfunc)(currentX, currentGrad);
98  
99    return currentGrad;
100  
101   }
102  
103 < vector<double> ConcreteNLMode1::calcGrad(vector<double>& x){
103 > vector<double> ConcreteNLModel1::calcGrad(vector<double>& x){
104 >  vector<double> tempGrad(x.size());
105  
96  vector<double> tempGrad(x.szie());
97
106    double tempF;
107    
108    tempF = (*objfunc)(x, tempGrad);
# Line 102 | Line 110 | SymMatrix ConcreteNLMode1::calcHessian(){
110    return tempGrad;
111   }
112  
113 < SymMatrix ConcreteNLMode1::calcHessian(){
113 >
114 > SymMatrix ConcreteNLModel1::calcHessian(){
115    calcGrad(currentX);
116 <  return FiniteHessian(currentX);
116 >  
117 >  return FiniteHessian(currentX, currentX);
118   }
119  
120 < SymMatrix ConcreteNLMode1::calcHessian(vector<double>& x){
121 <  return FiniteHessian(x);
120 > SymMatrix ConcreteNLModel1::calcHessian(vector<double>& x){
121 >  return FiniteHessian(x, x);
122   }
123 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines