Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65801555
functions.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jun 6, 08:08
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Jun 8, 08:08 (2 d)
Engine
blob
Format
Raw Data
Handle
18129367
Attached To
R9686 PCSCproject
functions.cpp
View Options
//
// Created by lionel on 11.12.19.
//
#include "functions.h"
double mylinear(double t){
return t;
}
double myzero(double t){
return 0;
}
FunctionType RHSFunctionFactory::parseType(int functionNumber) {
switch (functionNumber){
case 0 :
return Zero;
case 1 :
return Linear;
case 2 :
return Cosine;
default:
throw std::invalid_argument("Could not comprehend the function of input.");
}
}
std::function<Eigen::VectorXd(double)> RHSFunctionFactory::constructTimeDependantFunction(Eigen::VectorXd & list) {
int d = list.size(); // gets the dimension of the output
return [d, list](double t) {
Eigen::VectorXd result(d); // set the output
for (int i = 0; i < d; ++i) { // each dimension has to get another function
result[i] = getFunction(parseType((int)list[i]))(t);
}
return result;
};
}
double (* RHSFunctionFactory::getFunction(FunctionType f))(double t){
switch (f){
case Linear:
return mylinear;
case Cosine:
return cos;
case Zero:
return myzero;
default :
throw std::invalid_argument("Function type was not implemented.");
}
}
Event Timeline
Log In to Comment