23 #include "../wrappers/rng/rng.h" 30 (
const GiNaC::matrix& func,
31 const vector<GiNaC::symbol>& u,
32 const vector<GiNaC::symbol>& x,
34 const vector<GiNaC::symbol>& cond )
40 cond_size (cond_sym.size()),
41 u_size (u_sym.size()),
42 x_size (x_sym.size()),
43 func_size (func_sym.rows()),
44 dfunc_dcond (cond_size),
48 assert (func_sym.cols() == 1);
52 for (
unsigned int i=0; i < cond_size; i++)
53 dfunc_dcond[i] = func_sym.diff(cond_sym[i]);
56 for (
unsigned int i=0; i < x_size; i++)
57 dfunc_dx[i] = func_sym.diff(x_sym[i]);
62 (
const GiNaC::matrix& func,
63 const vector<GiNaC::symbol>& u,
64 const vector<GiNaC::symbol>& x,
71 u_size (u_sym.size()),
72 x_size (x_sym.size()),
73 func_size (func_sym.rows()),
77 assert (func_sym.cols() == 1);
80 for (
unsigned int i=0; i < x_size; i++)
81 dfunc_dx[i] = func_sym.diff(x_sym[i]);
91 cond_size (cond_sym.size()),
92 u_size (u_sym.size()),
93 x_size (x_sym.size()),
94 func_size (func_sym.rows()),
95 dfunc_dcond (cond_size),
99 assert (func_sym.cols() == 1);
103 for (
unsigned int i=0; i<cond_size; i++)
104 dfunc_dcond[i] = func_sym.diff(cond_sym[i]);
107 for (
unsigned int i=0; i < x_size; i++)
108 dfunc_dx[i] = func_sym.diff(x_sym[i]);
118 os <<
"function: " << p.
func_size << endl;
119 os <<
"input: " << p.
u_size << endl;
120 os <<
"State: " << p.
x_size << endl;
121 os <<
"Conditional: " << ((p.
cond_size) !=0) << endl;
126 MatrixWrapper::ColumnVector
129 MatrixWrapper::ColumnVector u_num (
u_size);
130 MatrixWrapper::ColumnVector x_num (
x_size);
131 MatrixWrapper::ColumnVector func_num(
func_size);
133 MatrixWrapper::ColumnVector expected(
func_size);
140 for (
unsigned int i=0; i<
u_size; i++)
153 for (
unsigned int j=0; j<
u_size; j++)
154 substitute = substitute.subs(
u_sym[j]==u_num(j+1) );
157 for (
unsigned int j=0; j<
x_size; j++)
158 substitute = substitute.subs(
x_sym[j]==x_num(j+1) );
161 func_num(i+1) = GiNaC::ex_to<GiNaC::numeric>( substitute.evalf() ).to_double();
172 MatrixWrapper::SymmetricMatrix
177 MatrixWrapper::ColumnVector u_num (
u_size);
178 MatrixWrapper::ColumnVector x_num (
x_size);
192 for (
unsigned int j=0; j<
u_size; j++)
193 substitute = substitute.subs(
u_sym[j]==u_num(j+1) );
196 for (
unsigned int j=0; j<
x_size; j++)
197 substitute = substitute.subs(
x_sym[j]==x_num(j+1) );
200 GiNaC::matrix substitute_matrix = GiNaC::ex_to<GiNaC::matrix>(substitute);
204 D(j+1,i+1) = GiNaC::ex_to<GiNaC::numeric>( substitute_matrix(j,0).evalf() ).to_double();
211 MatrixWrapper::SymmetricMatrix additiveNoise(temp.rows());
212 temp.convertToSymmetricMatrix(additiveNoise);
213 return additiveNoise;
223 MatrixWrapper::Matrix
230 MatrixWrapper::ColumnVector u_num (
u_size);
231 MatrixWrapper::ColumnVector x_num (
x_size);
239 for (
unsigned int i=0; i<
x_size; i++)
245 for (
unsigned int j=0; j<
u_size; j++)
246 substitute = substitute.subs(
u_sym[j]==u_num(j+1) );
249 for (
unsigned int j=0; j<
x_size; j++)
250 substitute = substitute.subs(
x_sym[j]==x_num(j+1) );
253 GiNaC::matrix substitute_matrix = GiNaC::ex_to<GiNaC::matrix>(substitute);
257 F(j+1,i+1) = GiNaC::ex_to<GiNaC::numeric>( substitute_matrix(j,0).evalf() ).to_double();
272 vector<GiNaC::symbol>
278 vector<GiNaC::symbol>
284 vector<GiNaC::symbol>
288 return vector<GiNaC::symbol>(0);
vector< GiNaC::symbol > InputGet()
return substitution symbols
vector< GiNaC::ex > dfunc_dcond
friend std::ostream & operator<<(std::ostream &os, NonLinearAnalyticConditionalGaussian_Ginac &p)
output stream for measurement model
Class representing Gaussian (or normal density)
const MatrixWrapper::ColumnVector & AdditiveNoiseMuGet() const
Get the mean Value of the Additive Gaussian uncertainty.
Conditional Gaussian for an analytic nonlinear system using Ginac:
vector< GiNaC::symbol > cond_sym
vector< GiNaC::symbol > x_sym
vector< GiNaC::symbol > u_sym
Abstract Class representing all full Analytical Conditional gaussians with Additive Gaussian Noise...
NonLinearAnalyticConditionalGaussian_Ginac(const GiNaC::matrix &func, const vector< GiNaC::symbol > &u, const vector< GiNaC::symbol > &x, const Gaussian &additiveNoise, const vector< GiNaC::symbol > &cond)
constructor
GiNaC::matrix FunctionGet()
return function
vector< GiNaC::symbol > ConditionalGet()
Get conditional arguments.
const MatrixWrapper::SymmetricMatrix & AdditiveNoiseSigmaGet() const
Get the covariance matrix of the Additive Gaussian uncertainty.
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
virtual MatrixWrapper::ColumnVector ExpectedValueGet() const
Get the expected value E[x] of the pdf.
const MatrixWrapper::ColumnVector & ConditionalArgumentGet(unsigned int n_argument) const
Get the n-th argument of the list.
unsigned int DimensionGet() const
Get the dimension of the argument.
virtual ~NonLinearAnalyticConditionalGaussian_Ginac()
Destructor.
vector< GiNaC::ex > dfunc_dx
vector< GiNaC::symbol > StateGet()
return state symbols
virtual MatrixWrapper::Matrix dfGet(unsigned int i) const