numerics 0.1.0
Loading...
Searching...
No Matches
raw.hpp File Reference

Tier-1 kernel: raw-pointer, inline, zero-overhead inner loops. More...

#include "core/types.hpp"
#include <cmath>
#include <concepts>

Go to the source code of this file.

Namespaces

namespace  num
 
namespace  num::kernel
 
namespace  num::kernel::raw
 

Macros

#define NUM_K_AINLINE   inline
 
#define NUM_K_RESTRICT
 
#define NUM_K_IVDEP
 

Functions

template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::scale (T *NUM_K_RESTRICT x, T alpha, idx n) noexcept
 x[i] *= alpha
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::axpy (T *NUM_K_RESTRICT y, const T *NUM_K_RESTRICT x, T alpha, idx n) noexcept
 y[i] += alpha * x[i]
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::axpby (T *NUM_K_RESTRICT y, const T *NUM_K_RESTRICT x, T a, T b, idx n) noexcept
 y[i] = a*x[i] + b*y[i].
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::axpbyz (T *NUM_K_RESTRICT z, const T *NUM_K_RESTRICT x, const T *NUM_K_RESTRICT y, T a, T b, idx n) noexcept
 z[i] = a*x[i] + b*y[i].
 
template<std::floating_point T>
NUM_K_AINLINEnum::kernel::raw::dot (const T *NUM_K_RESTRICT x, const T *NUM_K_RESTRICT y, idx n) noexcept
 dot product: return sum x[i] * y[i]
 
template<std::floating_point T>
NUM_K_AINLINEnum::kernel::raw::norm_sq (const T *NUM_K_RESTRICT x, idx n) noexcept
 sum x[i]^2 (no sqrt; use for convergence checks to avoid sqrt cost)
 
template<std::floating_point T>
NUM_K_AINLINEnum::kernel::raw::norm (const T *NUM_K_RESTRICT x, idx n) noexcept
 Euclidean norm: sqrt(sum x[i]^2)
 
template<std::floating_point T>
NUM_K_AINLINEnum::kernel::raw::l1_norm (const T *NUM_K_RESTRICT x, idx n) noexcept
 L1 norm: sum |x[i]|.
 
template<std::floating_point T>
NUM_K_AINLINEnum::kernel::raw::linf_norm (const T *NUM_K_RESTRICT x, idx n) noexcept
 L-infinity norm: max |x[i]|.
 
template<std::floating_point T>
NUM_K_AINLINEnum::kernel::raw::sum (const T *NUM_K_RESTRICT x, idx n) noexcept
 Scalar sum: return sum x[i].
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::matvec (T *NUM_K_RESTRICT y, const T *NUM_K_RESTRICT A, const T *NUM_K_RESTRICT x, idx m, idx n) noexcept
 y[i] = sum_j A[i*n + j] * x[j] (m x n row-major matrix)
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::ger (T *NUM_K_RESTRICT A, const T *NUM_K_RESTRICT x, const T *NUM_K_RESTRICT y, T alpha, idx m, idx n) noexcept
 Rank-1 update: A[i*n + j] += alpha * x[i] * y[j] (m x n row-major)
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::trsv_lower (T *NUM_K_RESTRICT x, const T *NUM_K_RESTRICT L, const T *NUM_K_RESTRICT b, idx n) noexcept
 Forward substitution: solve Lx = b, L lower triangular (n x n, row-major).
 
template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::trsv_upper (T *NUM_K_RESTRICT x, const T *NUM_K_RESTRICT U, const T *NUM_K_RESTRICT b, idx n) noexcept
 Back substitution: solve Ux = b, U upper triangular (n x n, row-major).
 

Detailed Description

Tier-1 kernel: raw-pointer, inline, zero-overhead inner loops.

Raw kernels assume non-owning, caller-sized buffers and do not allocate.

Definition in file raw.hpp.

Macro Definition Documentation

◆ NUM_K_AINLINE

#define NUM_K_AINLINE   inline

Definition at line 16 of file raw.hpp.

◆ NUM_K_IVDEP

#define NUM_K_IVDEP

Definition at line 18 of file raw.hpp.

◆ NUM_K_RESTRICT

#define NUM_K_RESTRICT

Definition at line 17 of file raw.hpp.