Public API
This page lists exported symbols of CTFlowsStaticArrays.
From CTFlowsStaticArrays
CTFlowsStaticArrays [Module]
CTFlowsStaticArrays — Module
CTFlowsStaticArrays
Extension module providing type-stable support for StaticArrays.SVector and SMatrix in Hamiltonian flows.
This module extends the internal _ham_split function to handle SVector and SMatrix inputs efficiently when the state dimension N is known at compile time. This enables zero-allocation operations for Hamiltonian systems with immutable array types.
Extension Details
The extension provides:
_ham_split(u::SVector, N::Int): Type-stable splitting ofSVectorinto(x, p)components usingSVectorconstructors._ham_split(u::SMatrix, N::Int): Type-stable splitting ofSMatrixinto(X, P)components usingSMatrixconstructors.
Usage
Load the extension with using CTFlowsStaticArrays after loading CTFlows:
using CTFlows
using CTFlowsStaticArrays # Loads this extension
# Now HamiltonianFlow works efficiently with SVector
hvf = HamiltonianVectorField((x, p) -> (p, -x); is_autonomous=true, is_variable=false)
flow = Flow(hvf; reltol=1e-8)
xf, pf = flow(0.0, SA[1.0, 0.0], SA[0.0, 1.0], π/2)
# And with SMatrix for matrix initial conditions
X0 = SA[1.0 2.0; 3.0 4.0]
P0 = SA[0.0 0.0; 1.0 1.0]
Xf, Pf = flow(0.0, X0, P0, π/2)Notes
- This extension is optional and only needed when using
StaticArrays.SVectororSMatrixwith Hamiltonian flows. - For standard
VectororMatrixtypes, the base implementation inCTFlows.Systemshandles splitting correctly.