5 QuadraticFunction::QuadraticFunction(
Variable& x,
int dimension)
14 ,_inhibitPropagationFrom_q_or_r(false)
16 for (
int i=0; i<dimension; ++i)
23 for (
size_t i=0; i<
_q.size(); ++i)
35 &&
"Pi does not have the good dimensions");
37 propagate<EVT_CHANGE_VALUE>();
48 propagate<EVT_CHANGE_VALUE>();
57 propagate<EVT_CHANGE_VALUE>();
62 ocra_assert((Pi-Pi.transpose()).isZero() &&
"Pi is not symmetric");
79 for (
int i=0; i<
_dim; ++i)
81 const MatrixXd& Pi =
getPi(i);
92 for (
int i=0; i<
_dim; ++i)
94 const MatrixXd& Pi =
getPi(i);
117 for (
int i=0; i<
_dim; ++i)
124 if (oldDimension <
_dim)
126 for (
int i=oldDimension; i<
_dim; ++i)
131 for (
int i=oldDimension-1; i>=
_dim; --i)
146 propagate<EVT_CHANGE_VALUE>(timestamp);
152 propagate<EVT_CHANGE_VALUE>(timestamp);
157 _inhibitPropagationFrom_q_or_r =
true;
162 _inhibitPropagationFrom_q_or_r =
false;
172 MatrixXd Q = MatrixXd::Random(5,5);
173 MatrixXd P = 0.5*(Q + Q.transpose());
174 VectorXd q = VectorXd::Random(5);
175 double r = VectorXd::Random(1)[0];
180 std::cout << qf.
getValue() << std::endl << std::endl;
181 std::cout << qf.
getJacobian() << std::endl << std::endl;
182 std::cout << qf.
get<
PARTIAL_XX>(0) << std::endl << std::endl;
187 x.
setValue(VectorXd::Constant(5, 1));
193 std::cout << qf.
getValue() << std::endl << std::endl;
194 std::cout << qf.
getJacobian() << std::endl << std::endl;
195 std::cout << qf.
get<
PARTIAL_XX>(0) << std::endl << std::endl;
virtual void updater() const
Computation ability of a ocra function.
void invalidateq(int timestamp)
virtual void doChangeqi(const VectorXd &qi, int index)
void inhibitPropagationFrom_q_or_r() const
const VectorXd & getValue() const
void changePi(const MatrixXd &Pi, int index=0)
void setValue(const VectorXd &value)
virtual void doChangePi(const MatrixXd &Pi, int index)
void testQuadraticFunction()
virtual void updateq() const
virtual void updateValue() const
virtual void doChangeri(double ri, int index)
virtual void updateJacobian() const
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
const IFunction< Ability >::return_type & get() const
virtual void doUpdateInputSizeEnd()
const MatrixXd & getJacobian() const
const VectorXd & getqi(int index=0) const
void changeqi(const VectorXd &qi, int index=0)
std::vector< VectorXd * > _q
This class represents a variable in a mathematical sense.
void desinhibitPropagationFrom_q_or_r() const
const MatrixXd & getPi(int index=0) const
virtual void updateHessian() const
const VectorXd & getValue() const
void changeri(double ri, int index=0)
virtual ~QuadraticFunction()
void invalidater(int timestamp)
const VectorXd & getr() const
#define ocra_assert(ocra_expression)
virtual void doUpdateDimensionEnd(int oldDimension)
Implements a basic variable.
Declaration file of the QuadraticFunction class.