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
11class Inertia {
12 public:
14 int positive = 0;
16 int negative = 0;
18 int zero = 0;
19
20 constexpr Inertia() = default;
21
28 constexpr Inertia(int positive, int negative, int zero)
30
36 template <typename Scalar>
37 explicit Inertia(const Eigen::Vector<Scalar, Eigen::Dynamic>& D) {
38 for (const auto& elem : D) {
39 if (elem > Scalar(0)) {
40 ++positive;
41 } else if (elem < Scalar(0)) {
42 ++negative;
43 } else {
44 ++zero;
45 }
46 }
47 }
48
54 template <typename Scalar>
55 explicit Inertia(
56 const Eigen::Diagonal<
57 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>>& D) {
58 for (const auto& elem : D) {
59 if (elem > Scalar(0)) {
60 ++positive;
61 } else if (elem < Scalar(0)) {
62 ++negative;
63 } else {
64 ++zero;
65 }
66 }
67 }
68
72 bool operator==(const Inertia&) const = default;
73};
74
75} // namespace slp
Definition inertia.hpp:11
int zero
The number of zero eigenvalues.
Definition inertia.hpp:18
Inertia(const Eigen::Diagonal< const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > > &D)
Definition inertia.hpp:55
constexpr Inertia(int positive, int negative, int zero)
Definition inertia.hpp:28
bool operator==(const Inertia &) const =default
int positive
The number of positive eigenvalues.
Definition inertia.hpp:14
Inertia(const Eigen::Vector< Scalar, Eigen::Dynamic > &D)
Definition inertia.hpp:37
int negative
The number of negative eigenvalues.
Definition inertia.hpp:16
Definition intrusive_shared_ptr.hpp:27