Sleipnir C++ API
Loading...
Searching...
No Matches
inertia.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <Eigen/Core>
6
7namespace slp {
8
13class Inertia {
14 public:
16 int positive = 0;
18 int negative = 0;
20 int zero = 0;
21
22 constexpr Inertia() = default;
23
32 constexpr Inertia(int positive, int negative, int zero)
34
42 template <typename Scalar>
43 explicit Inertia(const Eigen::Vector<Scalar, Eigen::Dynamic>& D) {
44 for (const auto& elem : D) {
45 if (elem > Scalar(0)) {
46 ++positive;
47 } else if (elem < Scalar(0)) {
48 ++negative;
49 } else {
50 ++zero;
51 }
52 }
53 }
54
62 template <typename Scalar>
63 explicit Inertia(
64 const Eigen::Diagonal<
65 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>>& D) {
66 for (const auto& elem : D) {
67 if (elem > Scalar(0)) {
68 ++positive;
69 } else if (elem < Scalar(0)) {
70 ++negative;
71 } else {
72 ++zero;
73 }
74 }
75 }
76
82 bool operator==(const Inertia&) const = default;
83};
84
85} // namespace slp
Definition inertia.hpp:13
int zero
The number of zero eigenvalues.
Definition inertia.hpp:20
Inertia(const Eigen::Diagonal< const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > > &D)
Definition inertia.hpp:63
constexpr Inertia(int positive, int negative, int zero)
Definition inertia.hpp:32
bool operator==(const Inertia &) const =default
int positive
The number of positive eigenvalues.
Definition inertia.hpp:16
Inertia(const Eigen::Vector< Scalar, Eigen::Dynamic > &D)
Definition inertia.hpp:43
int negative
The number of negative eigenvalues.
Definition inertia.hpp:18
Definition intrusive_shared_ptr.hpp:29