DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
state_creator.hpp
1#pragma once
2#include <core/concepts.hpp>
3
4// Helper trait to create state objects - shared among all integrators
5template<system_state S>
7 static S create(const S& template_state) {
8 if constexpr (requires { S(template_state.size()); }) {
9 // For containers like std::vector that can be constructed with size
10 return S(template_state.size());
11 } else {
12 // For fixed-size containers like std::array, copy and zero out
13 S result = template_state;
14 for (auto& val : result) {
15 val = typename S::value_type{};
16 }
17 return result;
18 }
19 }
20};