-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction.cpp
More file actions
25 lines (22 loc) · 1013 Bytes
/
Function.cpp
File metadata and controls
25 lines (22 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "Function.h"
void Function::MargeVatiable(std::list<std::string> listR, std::list<std::string> listL)
{
this->variables.merge(listR);
this->variables.merge(listL);
this->variables.sort();
this->variables.unique();//remove duplicate
if(this->variables.size()>1)//remove NON
this->variables.remove("NoN");
}
std::map<std::string, std::map<std::string, SharedPtr<Function> > > Function::Hessian() const
{
std::map<std::string, std::map<std::string, SharedPtr<Function> > > hessianMatrix;
for(std::list<std::string>::const_iterator i = this->variables.begin(); i != this->variables.end(); ++i){
SharedPtr<Function> firsDeriveByi = this->DeriveBy(*i);
for(std::list<std::string>::const_iterator j = this->variables.begin(); j != this->variables.end(); ++j){
SharedPtr<Function> secDeriveByj = firsDeriveByi->DeriveBy(*j);
hessianMatrix[*i][*j] = secDeriveByj;
}
}
return hessianMatrix;
}