GCC Code Coverage Report


Directory: ./
File: src/math/constraint-inequality.cpp
Date: 2024-11-10 01:12:44
Exec Total Coverage
Lines: 0 43 0.0%
Branches: 0 58 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2017 CNRS
3 //
4 // This file is part of tsid
5 // tsid is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 // tsid is distributed in the hope that it will be
10 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Lesser Public License for more details. You should have
13 // received a copy of the GNU Lesser General Public License along with
14 // tsid If not, see
15 // <http://www.gnu.org/licenses/>.
16 //
17
18 #include <tsid/math/constraint-inequality.hpp>
19
20 using namespace tsid::math;
21
22 ConstraintInequality::ConstraintInequality(const std::string& name)
23 : ConstraintBase(name) {}
24
25 ConstraintInequality::ConstraintInequality(const std::string& name,
26 const unsigned int rows,
27 const unsigned int cols)
28 : ConstraintBase(name, rows, cols),
29 m_lb(Vector::Zero(rows)),
30 m_ub(Vector::Zero(rows)) {}
31
32 ConstraintInequality::ConstraintInequality(const std::string& name,
33 ConstRefMatrix A, ConstRefVector lb,
34 ConstRefVector ub)
35 : ConstraintBase(name, A), m_lb(lb), m_ub(ub) {
36 PINOCCHIO_CHECK_INPUT_ARGUMENT(A.rows() == lb.rows(),
37 "The number of rows of A and lb do not match");
38 PINOCCHIO_CHECK_INPUT_ARGUMENT(A.rows() == ub.rows(),
39 "The number of rows of A and ub do not match");
40 }
41
42 unsigned int ConstraintInequality::rows() const {
43 assert(m_A.rows() == m_lb.rows());
44 assert(m_A.rows() == m_ub.rows());
45 return (unsigned int)m_A.rows();
46 }
47
48 unsigned int ConstraintInequality::cols() const {
49 return (unsigned int)m_A.cols();
50 }
51
52 void ConstraintInequality::resize(const unsigned int r, const unsigned int c) {
53 m_A.setZero(r, c);
54 m_lb.setZero(r);
55 m_ub.setZero(r);
56 }
57
58 bool ConstraintInequality::isEquality() const { return false; }
59 bool ConstraintInequality::isInequality() const { return true; }
60 bool ConstraintInequality::isBound() const { return false; }
61
62 const Vector& ConstraintInequality::vector() const {
63 assert(false);
64 return m_lb;
65 }
66 const Vector& ConstraintInequality::lowerBound() const { return m_lb; }
67 const Vector& ConstraintInequality::upperBound() const { return m_ub; }
68
69 Vector& ConstraintInequality::vector() {
70 assert(false);
71 return m_lb;
72 }
73 Vector& ConstraintInequality::lowerBound() { return m_lb; }
74 Vector& ConstraintInequality::upperBound() { return m_ub; }
75
76 bool ConstraintInequality::setVector(ConstRefVector) {
77 assert(false);
78 return false;
79 }
80 bool ConstraintInequality::setLowerBound(ConstRefVector lb) {
81 m_lb = lb;
82 return true;
83 }
84 bool ConstraintInequality::setUpperBound(ConstRefVector ub) {
85 m_ub = ub;
86 return true;
87 }
88
89 bool ConstraintInequality::checkConstraint(ConstRefVector x, double tol) const {
90 return ((m_A * x).array() <= m_ub.array() + tol).all() &&
91 ((m_A * x).array() >= m_lb.array() - tol).all();
92 }
93