Source
stdlib/linalg/enums.hpp
1
// Copyright (c) 2026 BigBrain LLC. MIT-licensed (see LICENSE).2
// Original work; see ACKNOWLEDGMENTS.md for the open-source ideas we build upon.3
#pragma once5
/**6
* @file enums.hpp7
* @brief cheatah `linalg` — operation-variant enums used as non-type template parameters.8
*9
* Where two or more routines differ only by a compile-time choice, that choice is an `enum`10
* NTTP `if constexpr`-branched inside ONE templated body — so the variants share a single11
* definition and the compiler emits only the selected branch (zero runtime cost, no dead12
* loads). This keeps the maintained surface small while staying the fastest possible per13
* instantiation.14
*/16
namespace cheatah::linalg {18
/// Whether a reduction conjugates its first operand. `dot`/`inner` are bilinear (`Conj::None`,19
/// Σ aᵢbᵢ); `vdot` is the conjugate-linear Hermitian inner product (`Conj::Conjugate`,20
/// Σ conj(aᵢ)·bᵢ). For a REAL element the conjugate is the identity, so both fold to the same21
/// code via `if constexpr (is_complex_v<T> && mode == Conj::Conjugate)`.22
enum class Conj { None, Conjugate };24
} // namespace cheatah::linalg