Sleipnir C++ API
Loading...
Searching...
No Matches
inertia.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <format>
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
34 bool operator==(const Inertia&) const = default;
35};
36
37} // namespace slp
38
40template <>
41struct std::formatter<slp::Inertia> {
46 constexpr auto parse(std::format_parse_context& ctx) {
47 return m_underlying.parse(ctx);
48 }
49
56 template <typename FmtContext>
57 auto format(const slp::Inertia& inertia, FmtContext& ctx) const {
58 auto out = ctx.out();
59
60 out = std::format_to(out, "(");
61 out = m_underlying.format(inertia.positive, ctx);
62 out = std::format_to(out, ", ");
63 out = m_underlying.format(inertia.negative, ctx);
64 out = std::format_to(out, ", ");
65 out = m_underlying.format(inertia.zero, ctx);
66 return std::format_to(out, ")");
67 }
68
69 private:
70 std::formatter<int> m_underlying;
71};
Definition inertia.hpp:11
int zero
The number of zero eigenvalues.
Definition inertia.hpp:18
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
int negative
The number of negative eigenvalues.
Definition inertia.hpp:16
constexpr auto parse(std::format_parse_context &ctx)
Definition inertia.hpp:46
auto format(const slp::Inertia &inertia, FmtContext &ctx) const
Definition inertia.hpp:57