KalmanFilter
Public Member Functions | List of all members
continuousModel< T > Class Template Referenceabstract

#include <model.h>

Inheritance diagram for continuousModel< T >:
Inheritance graph
[legend]
Collaboration diagram for continuousModel< T >:
Collaboration graph
[legend]

Public Member Functions

virtual T function (const T &val, const double time) const =0
 

Detailed Description

template<typename T>
class continuousModel< T >

Abstract continuousModel inherits from model<double> and thus specifies that time is continuous. Class only declares single pure virtual method 'function' that describes a ODE where returned value is is the derivative of T evaluated at a specific time and value T. T is the data type whether double, Eigen or custom implemented.

Following two examples implement the same differential equation but using different T's.

Example using double

#include <iostream>
#include "../../include/model.h"
int main(){
//class will model one of the most simplest differential equations dy/dt = -0.1*y
class odeSimpleExample: public continuousModel<double>{
//implementing the pure virtual function
public:
double function(const double & val, const double time) const override{
double rhs = -0.1*val;
return rhs;
}
};
odeSimpleExample ose;//actual instance of class
double timeEvaluatedAt = 10;
double valueAtTime = 1;
std::cout<<ose.function(valueAtTime,timeEvaluatedAt)<<std::endl;
/* produces the output:
* -0.1
*/
};

Example using Eigen

#include <Eigen/Dense>
#include <iostream>
#include "../../include/model.h"
int main(){
//using the Eigen library to implement the exact same class (conceptually) as above
class odeSimpleExampleEigen: public continuousModel<Eigen::VectorXd>{
private:
Eigen::MatrixXd modelMatrix;
public:
//can add constructor to make your model more adjustable and reusable
odeSimpleExampleEigen(double exp){
Eigen::MatrixXd tmp(1,1);
tmp<<exp;
modelMatrix = tmp;
}
Eigen::VectorXd function(const Eigen::VectorXd & val, const double time) const override{
return modelMatrix*val;
}
};
double exponent = -0.1;
odeSimpleExampleEigen ose2(exponent);
double timeEvaluatedAt = 10;
double valueAtTime = 1;
Eigen::VectorXd tmp(1); tmp<<valueAtTime;
std::cout<<ose2.function(tmp,timeEvaluatedAt) <<std::endl;
/* produces the output:
* -0.1
*/
};

Member Function Documentation

◆ function()

template<typename T>
virtual T continuousModel< T >::function ( const T &  val,
const double  time 
) const
pure virtual

Pure virtual function. User is responsible for implementing this method in inherited class. The function returns rhs (right hand side) where rhs = diff(T,t) = function(T,t) where rhs is the derivative of variable T at time t.

User is also responsible for specifying data type T.


The documentation for this class was generated from the following file: