ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/NLModel1.cpp
Revision: 996
Committed: Wed Jan 28 22:44:44 2004 UTC (20 years, 5 months ago) by tim
File size: 1556 byte(s)
Log Message:
Revision of NLModel0 and NLModel1

File Contents

# Content
1 #include "NLModel.hpp"
2 //calculate hessian using finite difference
3 SymMatrix NLModel1::FiniteHessian(vector<double>& x, vector<double>& h){
4
5 SymMatrix hessian(ndim);
6 vector<double> gplus;
7 vector<double> tempX;
8 double hi;
9
10 #ifdef IS_MPI
11 vector<double> gplusAll;
12 vector<double> currentGradAll;
13
14 currentGradAll = getAllGrad();
15 #endif
16
17 tempX = x;
18
19 for(int i = 0; i < ndim; i++){
20
21 #ifndef IS_MPI
22 hi = copysign(h[i], tempX[i]);
23
24 tempX[i] += hi;
25
26 gplus = calcGrad(tempX);
27
28 hessian.Cloume(i) = (gplus - currentGrad) / hi;
29
30 //restore tempX to its original value
31 tempX[i] -= hi;
32 #else
33 if(procMappingArray[i] == myRank){
34
35 hi = copysign(h[i], tempX[i]);
36 tempX[i] += hi;
37
38 }
39
40 gplus = calcGrad(tempX);
41
42 gplusAll.clear();
43
44 //very inefficient, need to change
45 for(int j = 0; j , numOfProc; j++){
46 brocastVector(gplus, j);
47 gplusAll.insert(gplus);
48 }
49
50 if(procMappingArray[i] == myRank){
51
52 hi = copysign(h[i], tempX[i]);
53 tempX[i] += hi;
54
55 }
56
57 hessian.Cloume(i) = (gplusAll - currentGradAll) / hi;
58 #endif
59
60 }
61
62 return hessian;
63
64 }
65
66 double ConcreteNLMode1::calcF(){
67
68 }
69
70 double ConcreteNLMode1::calcF(const vector<double>& x){
71
72 }
73
74 vector<double> ConcreteNLMode1::calcGrad(){
75
76 }
77
78 vector<double> ConcreteNLMode1::calcGrad(vector<double>& x){
79
80 }
81
82 SymMatrix ConcreteNLMode1::calcHessian(){
83
84 }
85
86 SymMatrix ConcreteNLMode1::calcHessian(vector<double>& x){
87
88 }

Properties

Name Value
svn:executable *