-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionMulti.cpp
More file actions
25 lines (19 loc) · 1.27 KB
/
FunctionMulti.cpp
File metadata and controls
25 lines (19 loc) · 1.27 KB
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 "FunctionMulti.h"
FunctionMulti::FunctionMulti(SharedPtr <Function> left, SharedPtr <Function> rigth): leftFunction(left),rigthFunction(rigth)
{
Function::MargeVatiable(rigth->Variables(), left->Variables());//marge the Lists
}
double FunctionMulti::Evaluate(const std::map<std::string, double> &variables) const
{
double sumRigth=this->rigthFunction->Evaluate(variables);//get the value of the rigth Funcrion
double sumLeft=this->leftFunction->Evaluate(variables);//get the value of the left Funcrion
return sumLeft*sumRigth;
}
SharedPtr<Function> FunctionMulti::DeriveBy(const std::string &variable) const
{
SharedPtr<Function> rigthDeriveMulti = this->rigthFunction->DeriveBy(variable);//get the derive of the rigth fuction
SharedPtr<Function> leftDeriveMulti = this->leftFunction->DeriveBy(variable);//get the derive of the left fuction
SharedPtr<Function> sumLeftFunction = new FunctionMulti(this->leftFunction,rigthDeriveMulti);//make new function for the rigth side of the derive
SharedPtr<Function> sumRigthFunction = new FunctionMulti(this->rigthFunction,leftDeriveMulti);//make new function for the left side of the derive
return new FunctionSum(sumLeftFunction,sumRigthFunction);//return poiter to the drived
}