GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bindings/python/crocoddyl/core/activations/quadratic.cpp Lines: 12 12 100.0 %
Date: 2024-02-13 11:12:33 Branches: 9 18 50.0 %

Line Branch Exec Source
1
///////////////////////////////////////////////////////////////////////////////
2
// BSD 3-Clause License
3
//
4
// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
5
//                          Heriot-Watt University
6
// Copyright note valid unless otherwise stated in individual files.
7
// All rights reserved.
8
///////////////////////////////////////////////////////////////////////////////
9
10
#include "crocoddyl/core/activations/quadratic.hpp"
11
12
#include "python/crocoddyl/core/activation-base.hpp"
13
#include "python/crocoddyl/core/core.hpp"
14
#include "python/crocoddyl/utils/copyable.hpp"
15
16
namespace crocoddyl {
17
namespace python {
18
19
10
void exposeActivationQuad() {
20
  boost::python::register_ptr_to_python<
21
10
      boost::shared_ptr<ActivationModelQuad> >();
22
23
10
  bp::class_<ActivationModelQuad, bp::bases<ActivationModelAbstract> >(
24
      "ActivationModelQuad",
25
      "Quadratic activation model.\n\n"
26
      "A quadratic action describes a quadratic function that depends on the "
27
      "residual, i.e.\n"
28
      "0.5 *||r||^2.",
29
20
      bp::init<int>(bp::args("self", "nr"),
30
                    "Initialize the activation model.\n\n"
31
                    ":param nr: dimension of the cost-residual vector"))
32
20
      .def("calc", &ActivationModelQuad::calc, bp::args("self", "data", "r"),
33
           "Compute the 0.5 * ||r||^2.\n\n"
34
           ":param data: activation data\n"
35
10
           ":param r: residual vector")
36
      .def("calcDiff", &ActivationModelQuad::calcDiff,
37
20
           bp::args("self", "data", "r"),
38
           "Compute the derivatives of a quadratic function.\n\n"
39
           "Note that the Hessian is constant, so we don't write again this "
40
           "value.\n"
41
           "It assumes that calc has been run first.\n"
42
           ":param data: activation data\n"
43
10
           ":param r: residual vector \n")
44
20
      .def("createData", &ActivationModelQuad::createData, bp::args("self"),
45
10
           "Create the quadratic activation data.\n\n")
46
10
      .def(CopyableVisitor<ActivationModelQuad>());
47
10
}
48
49
}  // namespace python
50
}  // namespace crocoddyl