Centipede 0.0.1
Centipede program
Loading...
Searching...
No Matches
entry.hpp
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6#include <format>
7#include <utility>
8
9namespace centipede
10{
18 template <std::size_t NLocals, std::size_t NGlobals>
20 {
21 using data_type = float;
22 using LocalDerivs = std::array<float, NLocals>;
23 using GlobalDerivs = std::array<std::pair<uint32_t, float>, NGlobals>;
24 static constexpr std::size_t n_locals = NLocals;
25 static constexpr std::size_t n_globals = NGlobals;
26
27 // NOLINTBEGIN (misc-non-private-member-variables-in-classes)
30 float measurement{};
31 float sigma{};
32 // NOLINTEND (misc-non-private-member-variables-in-classes)
33
37 constexpr void reset()
38 {
39 local_derivs = std::array<float, NLocals>{};
40 global_derivs = std::array<std::pair<uint32_t, float>, NGlobals>{};
41 measurement = float{};
42 sigma = float{};
43 }
44
48 constexpr auto operator<=>(const EntryPoint<NLocals, NGlobals>& other) const = default;
49 };
50
54 template <std::size_t NLocals, std::size_t NGlobals>
55 EntryPoint(std::array<float, NLocals>, std::array<std::pair<uint32_t, float>, NGlobals>, float, float)
57}; // namespace centipede
58
62template <std::size_t NLocals, std::size_t NGlobals>
63struct std::formatter<centipede::EntryPoint<NLocals, NGlobals>>
64{
65 static constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); }
66
67 static auto format(const centipede::EntryPoint<NLocals, NGlobals>& entry, std::format_context& ctx)
68 {
69 return std::format_to(ctx.out(),
70 "local derivatives: {}, global derivatives: {}, measurement: {}, sigma: {}",
71 entry.local_derivs,
72 entry.global_derivs,
73 entry.measurement,
74 entry.sigma);
75 }
76};
Types for errors.
Definition handler.cpp:5
EntryPoint(std::array< float, NLocals >, std::array< std::pair< uint32_t, float >, NGlobals >, float, float) -> EntryPoint< NLocals, NGlobals >
Explicit CTAD deduction guide for centipede::EntryPoint.
Structure of a entrypoint.
Definition entry.hpp:20
constexpr void reset()
Reset all values to the default values.
Definition entry.hpp:37
float data_type
Data type of deriv values.
Definition entry.hpp:21
float sigma
Error value.
Definition entry.hpp:31
std::array< float, NLocals > LocalDerivs
Data type of local deriv array.
Definition entry.hpp:22
std::array< std::pair< uint32_t, float >, NGlobals > GlobalDerivs
Data type of global deriv array.
Definition entry.hpp:23
float measurement
Measurement corresponding to the error value.
Definition entry.hpp:30
LocalDerivs local_derivs
Local derivatives.
Definition entry.hpp:28
static constexpr std::size_t n_globals
Number of the global parameters.
Definition entry.hpp:25
static constexpr std::size_t n_locals
Number of the local parameters.
Definition entry.hpp:24
GlobalDerivs global_derivs
Global label and derivatives pair. The label is using 0-based indexing.
Definition entry.hpp:29
constexpr auto operator<=>(const EntryPoint< NLocals, NGlobals > &other) const =default
Default spaceship operator for comparisons.