Skip to content

Math layer concepts reference

The branes::math headers are concept-constrained C++20. The concepts delegate the actual arithmetic requirements to MTL5’s operation-based scalar concepts, so the built-in floating-point types and the Universal number types (posit, cfloat, fixpnt, …) satisfy them without any per-type specialization. This page lists every public concept and its one-line semantics.

Defined in branes/math/arithmetic.hpp.

ConceptHeaderSemantics
branes::math::Scalar<T>arithmetic.hppA value type with the ring operations + - *, unary -, and a T{0} identity. Delegates to mtl::Scalar.
branes::math::Field<T>arithmetic.hppA Scalar that also supports division — the minimum for matrix–vector products, axpy, and normal-equation assembly. Delegates to mtl::Field.
branes::math::OrderedField<T>arithmetic.hppA Field that is totally ordered — required wherever the algorithms compare magnitudes (trust-region radii, line-search predicates, pivots). Real floats and real Universal types model it; complex types do not.
branes::math::LinearAlgebraScalar<T>arithmetic.hppThe element-type contract for the dense/sparse linear-algebra surface (MTL5 matvec / axpy / scaling). An intentional alias of Field; it names the requirement at solver call sites.
branes::math::TensorScalar<T>tensor.hppAn element type a TensorView may store and relocate: std::is_trivially_copyable_v<std::remove_const_t<T>>. Storage only — no arithmetic requirement (that is layered on by the solvers).

The math_type_smoke test instantiates a real MTL5 expression (y = A·x + b) for each of the following and checks the result:

  • IEEE binary: double, float
  • Universal posit: posit<32, 2>, posit<16, 1>
  • Universal cfloat: cfloat<32, 8, uint32_t, true, false, false>
  • Universal fixpnt: fixpnt<32, 16, Saturate>

Types not yet validated for the linear-algebra surface (tracked for later phases): lns, dd/qd, integer/decimal.

Defined in branes/math/tensor.hpp and branes/math/sparse.hpp. These are non-owning windows over caller-supplied buffers (the math layer never owns numeric storage — it operates on buffers handed across the cxx bridge from the Rust Resource Manager).

TypeHeaderRole
TensorView<T, Rank>tensor.hppDense multi-dimensional view over std::span<T> with a DLPack-style shape/stride descriptor (strides in elements). T models TensorScalar.
VectorView<T> / MatrixView<T>tensor.hppRank-1 / rank-2 aliases of TensorView.
CsrView<T, IndexT>sparse.hppCompressed-sparse-row view; T models Scalar.
CscView<T, IndexT>sparse.hppCompressed-sparse-column view.
CooView<T, IndexT>sparse.hppCoordinate-list view (duplicate coordinates accumulate).
ComponentHeaderElement-type constraint
cg / bicgstab / gmreskrylov.hppLinearAlgebraScalar (thin wrappers on MTL5 ITL)
SparseCholesky<T> / SparseLdlt<T>sparse_direct.hppScalar (MTL5 native sparse direct)
nls::solve (Gauss-Newton / Levenberg-Marquardt / Dogleg)nls/solver.hppmodel’s Scalar; analytical Jacobians only
lie::SO3<T> / SE3<T> / Sim3<T>lie/*.hppScalar (with ADL sqrt/sin/cos/… for transcendentals)
Terminal window
cmake -B build
cmake --build build --target docs-math # requires Doxygen
# HTML output under build/docs/math/html

The docs-math target is configured with WARN_AS_ERROR, so the build fails if any Doxygen comment is malformed — the headers are kept warning-clean.