Public API

This page lists exported symbols of CTFlowsStaticArrays.


From CTFlowsStaticArrays

CTFlowsStaticArrays [Module]

CTFlowsStaticArraysModule

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 of SVector into (x, p) components using SVector constructors.
  • _ham_split(u::SMatrix, N::Int): Type-stable splitting of SMatrix into (X, P) components using SMatrix constructors.

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.SVector or SMatrix with Hamiltonian flows.
  • For standard Vector or Matrix types, the base implementation in CTFlows.Systems handles splitting correctly.