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
#include <cstdint>18
namespace cheatah::linalg {20
/// Whether a reduction conjugates its first operand. `dot`/`inner` are bilinear (`Conj::None`,21
/// Σ aᵢbᵢ); `vdot` is the conjugate-linear Hermitian inner product (`Conj::Conjugate`,22
/// Σ conj(aᵢ)·bᵢ). For a REAL element the conjugate is the identity, so both fold to the same23
/// code via `if constexpr (is_complex_v<T> && mode == Conj::Conjugate)`.24
enum class Conj : std::uint8_t { None, Conjugate };26
} // namespace cheatah::linalg