10 #ifndef CROCODDYL_CORE_ACTIVATION_BASE_HPP_
11 #define CROCODDYL_CORE_ACTIVATION_BASE_HPP_
13 #include <boost/core/demangle.hpp>
14 #include <boost/make_shared.hpp>
15 #include <boost/shared_ptr.hpp>
18 #include "crocoddyl/core/fwd.hpp"
19 #include "crocoddyl/core/mathbase.hpp"
23 template <
typename _Scalar>
26 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
28 typedef _Scalar Scalar;
31 typedef typename MathBase::VectorXs VectorXs;
32 typedef typename MathBase::MatrixXs MatrixXs;
37 virtual void calc(
const boost::shared_ptr<ActivationDataAbstract>& data,
38 const Eigen::Ref<const VectorXs>& r) = 0;
39 virtual void calcDiff(
const boost::shared_ptr<ActivationDataAbstract>& data,
40 const Eigen::Ref<const VectorXs>& r) = 0;
41 virtual boost::shared_ptr<ActivationDataAbstract> createData() {
42 return boost::allocate_shared<ActivationDataAbstract>(
43 Eigen::aligned_allocator<ActivationDataAbstract>(),
this);
46 std::size_t get_nr()
const {
return nr_; };
62 virtual void print(std::ostream& os)
const {
63 os << boost::core::demangle(
typeid(*this).name());
70 template <
typename _Scalar>
72 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
74 typedef _Scalar Scalar;
76 typedef typename MathBase::VectorXs VectorXs;
77 typedef typename MathBase::MatrixXs MatrixXs;
78 typedef typename MathBase::DiagonalMatrixXs DiagonalMatrixXs;
80 template <
template <
typename Scalar>
class Activation>
82 : a_value(Scalar(0.)),
83 Ar(VectorXs::Zero(activation->get_nr())),
84 Arr(DiagonalMatrixXs(activation->get_nr())) {
93 static MatrixXs getHessianMatrix(
95 return data.Arr.diagonal().asDiagonal();
98 const MatrixXs& Arr) {
99 data.Arr.diagonal() = Arr.diagonal();
friend std::ostream & operator<<(std::ostream &os, const ActivationModelAbstractTpl< Scalar > &model)
Print information on the activation model.
virtual void print(std::ostream &os) const
Print relevant information of the activation model.