GCC Code Coverage Report


Directory: ./
File: src/jdifference-visitor.hh
Date: 2025-05-04 12:09:19
Exec Total Coverage
Lines: 0 15 0.0%
Branches: 0 48 0.0%

Line Branch Exec Source
1 // Copyright (c) 2018, CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28
29 #ifndef HPP_PINOCCHIO_SRC_JDIFFERENCE_VISITOR_HH
30 #define HPP_PINOCCHIO_SRC_JDIFFERENCE_VISITOR_HH
31
32 #include <hpp/pinocchio/liegroup/vector-space.hh>
33
34 namespace hpp {
35 namespace pinocchio {
36 using ::pinocchio::ARG0;
37 using ::pinocchio::ARG1;
38 using ::pinocchio::ArgumentPosition;
39
40 namespace liegroupType {
41 template <ArgumentPosition arg, DerivativeProduct side>
42 struct dDifferenceVisitor : public boost::static_visitor<> {
43 dDifferenceVisitor(vectorIn_t& q0, vectorIn_t& q1, matrixOut_t& J)
44 : q0_(q0), q1_(q1), J_(J), iq_(0), iv_(0) {}
45
46 template <typename LgT>
47 void operator()(const LgT& lg) {
48 typename LgT::JacobianMatrix_t Jint(lg.nv(), lg.nv());
49
50 lg.template dDifference<arg>(q0_.segment<LgT::NQ>(iq_, lg.nq()),
51 q1_.segment<LgT::NQ>(iq_, lg.nq()), Jint);
52 if (side == DerivativeTimesInput)
53 J_.middleRows<LgT::NV>(iv_, lg.nv()).applyOnTheLeft(Jint);
54 else
55 J_.middleCols<LgT::NV>(iv_, lg.nv()).applyOnTheRight(Jint);
56 iq_ += lg.nq();
57 iv_ += lg.nv();
58 }
59
60 template <int N, bool rot>
61 void operator()(const liegroup::VectorSpaceOperation<N, rot>& lg) {
62 if (arg == ARG0) {
63 if (side == DerivativeTimesInput)
64 J_.middleRows<N>(iv_, lg.nv()) *= -1;
65 else
66 J_.middleCols<N>(iv_, lg.nv()) *= -1;
67 }
68 iq_ += lg.nq();
69 iv_ += lg.nv();
70 }
71 vectorIn_t &q0_, q1_;
72 matrixOut_t& J_;
73 size_type iq_, iv_;
74 }; // struct dDifferenceVisitor
75 } // namespace liegroupType
76 } // namespace pinocchio
77 } // namespace hpp
78
79 #endif // HPP_PINOCCHIO_SRC_JDIFFERENCE_VISITOR_HH
80