10 #ifndef _OCRABASE_ROW_H_ 11 #define _OCRABASE_ROW_H_ 14 #include "ocra/optim/CompileTimeChecks.h" 35 class RowFunction :
public T::functionType_t,
private IsDerivedFrom<T, Function>
53 RowFunction(T*
function,
const std::vector<int>& indices);
103 :
Function(function->getVariable(), 1, function->getType(), function->getConvexityProperty(),
104 function->getContinuityProperty(),function->canComputeHessian(), function->canComputeGradient())
108 function->attach(*
this);
109 this->_name =
"rowFunction";
114 :
Function(function->getVariable(), (cfl_size_t)indices.size(), function->getType(), function->getConvexityProperty(),
115 function->getContinuityProperty(),function->canComputeHessian(), function->canComputeGradient())
118 assert(indices.size() <=
function->getDimension());
119 function->attach(*
this);
120 this->_name =
"rowFunction";
126 const Vector& v =
_f->getValues();
127 for (cfl_size_t i=0; i<this->_dimension; ++i)
134 const Matrix& g =
_f->getGradients();
135 for (cfl_size_t i=0; i<this->_dimension; ++i)
137 for (cfl_size_t j=0; j<this->_x->getSize(); ++j)
139 this->_gradient(i,j) = g(
_indices[i], j);
147 throw std::runtime_error(
"RowFunction<T>::computeHessian: method non implemented.");
148 for (cfl_size_t i=0; i<this->_dimension; ++i)
158 const Matrix& g =
_f->getJdot();
159 for (cfl_size_t i=0; i<this->_dimension; ++i)
161 for (cfl_size_t j=0; j<this->_x->getSize(); ++j)
163 this->_Jdot(i,j) = g(
_indices[i], j);
171 const Vector& v =
_f->getJdotXdot();
172 for (cfl_size_t i=0; i<this->_dimension; ++i)
174 this->_JdotXdot[i] = v[
_indices[i]];
185 #endif //_OCRABASE_ROW_H_ virtual void computeJdot(void) const
virtual void doUpdateSize(void)
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
std::vector< int > _indices
virtual void computeValue(void) const
virtual void computeGradient(void) const
Declaration file of the Function class.
virtual void computeJdotXdot(void) const
virtual void computeHessian(void) const