GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/math/constraint-equality.cpp Lines: 0 39 0.0 %
Date: 2024-02-02 08:47:34 Branches: 0 24 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-equality.hpp>
19
20
using namespace tsid::math;
21
22
ConstraintEquality::ConstraintEquality(const std::string& name)
23
    : ConstraintBase(name) {}
24
25
ConstraintEquality::ConstraintEquality(const std::string& name,
26
                                       const unsigned int rows,
27
                                       const unsigned int cols)
28
    : ConstraintBase(name, rows, cols), m_b(Vector::Zero(rows)) {}
29
30
ConstraintEquality::ConstraintEquality(const std::string& name,
31
                                       ConstRefMatrix A, ConstRefVector b)
32
    : ConstraintBase(name, A), m_b(b) {
33
  PINOCCHIO_CHECK_INPUT_ARGUMENT(A.rows() == b.rows(),
34
                                 "The number of rows for A and b do not match");
35
}
36
37
unsigned int ConstraintEquality::rows() const {
38
  assert(m_A.rows() == m_b.rows());
39
  return (unsigned int)m_A.rows();
40
}
41
42
unsigned int ConstraintEquality::cols() const {
43
  return (unsigned int)m_A.cols();
44
}
45
46
void ConstraintEquality::resize(const unsigned int r, const unsigned int c) {
47
  m_A.setZero(r, c);
48
  m_b.setZero(r);
49
}
50
51
bool ConstraintEquality::isEquality() const { return true; }
52
bool ConstraintEquality::isInequality() const { return false; }
53
bool ConstraintEquality::isBound() const { return false; }
54
55
const Vector& ConstraintEquality::vector() const { return m_b; }
56
const Vector& ConstraintEquality::lowerBound() const {
57
  assert(false);
58
  return m_b;
59
}
60
const Vector& ConstraintEquality::upperBound() const {
61
  assert(false);
62
  return m_b;
63
}
64
65
Vector& ConstraintEquality::vector() { return m_b; }
66
Vector& ConstraintEquality::lowerBound() {
67
  assert(false);
68
  return m_b;
69
}
70
Vector& ConstraintEquality::upperBound() {
71
  assert(false);
72
  return m_b;
73
}
74
75
bool ConstraintEquality::setVector(ConstRefVector b) {
76
  m_b = b;
77
  return true;
78
}
79
bool ConstraintEquality::setLowerBound(ConstRefVector) {
80
  assert(false);
81
  return false;
82
}
83
bool ConstraintEquality::setUpperBound(ConstRefVector) {
84
  assert(false);
85
  return false;
86
}
87
88
bool ConstraintEquality::checkConstraint(ConstRefVector x, double tol) const {
89
  return (m_A * x - m_b).norm() < tol;
90
}