A
askmeofit
I'm a Phd student in statistics, and I'm writing computer code for the
simulation of stochastic differential equations.
Little background about my knowledge: I know C programming decently,
and my main reference for C++ programming is the book: "C++ and Object-
oriented Numeric Computing for scientists and Engineers" which I
studied chapter to chapter 1 year ago and I'm in the process of
studying it again (I forget things easily....).
I would like to define a class to store the simulated path of the
stochastic process:
#include <iostream>
#include <valarray>
using namespace std;
class Path {
static long int maxsize;
public:
valarray<double> v; // values of the path
valarray<double> t; // at these times
long size; // actual lenght of the path
double x0, delta, T; // starting point , delta of
discretization, ending time
Path(long int n);
Path(); //default constructor
};
The problem is that now I don't know how to define the default
constructor.
I want to initialize v and t as follow:
valarray<double> v(maxsize);
valarray<double> t(maxsize);
Is there an easy way to do it?
Or do I have to revert to the usual pointer do data approach?
Thank you
StephQ
simulation of stochastic differential equations.
Little background about my knowledge: I know C programming decently,
and my main reference for C++ programming is the book: "C++ and Object-
oriented Numeric Computing for scientists and Engineers" which I
studied chapter to chapter 1 year ago and I'm in the process of
studying it again (I forget things easily....).
I would like to define a class to store the simulated path of the
stochastic process:
#include <iostream>
#include <valarray>
using namespace std;
class Path {
static long int maxsize;
public:
valarray<double> v; // values of the path
valarray<double> t; // at these times
long size; // actual lenght of the path
double x0, delta, T; // starting point , delta of
discretization, ending time
Path(long int n);
Path(); //default constructor
};
The problem is that now I don't know how to define the default
constructor.
I want to initialize v and t as follow:
valarray<double> v(maxsize);
valarray<double> t(maxsize);
Is there an easy way to do it?
Or do I have to revert to the usual pointer do data approach?
Thank you
StephQ