numerics 0.1.0
Loading...
Searching...
No Matches
num::kernel::raw Namespace Reference

Functions

template<std::floating_point T>
NUM_K_AINLINE void scale (T *NUM_K_RESTRICT x, T alpha, idx n) noexcept
 x[i] *= alpha
 
template<std::floating_point T>
NUM_K_AINLINE void 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 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 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_AINLINEdot (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_AINLINEnorm_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_AINLINEnorm (const T *NUM_K_RESTRICT x, idx n) noexcept
 Euclidean norm: sqrt(sum x[i]^2)
 
template<std::floating_point T>
NUM_K_AINLINEl1_norm (const T *NUM_K_RESTRICT x, idx n) noexcept
 L1 norm: sum |x[i]|.
 
template<std::floating_point T>
NUM_K_AINLINElinf_norm (const T *NUM_K_RESTRICT x, idx n) noexcept
 L-infinity norm: max |x[i]|.
 
template<std::floating_point T>
NUM_K_AINLINEsum (const T *NUM_K_RESTRICT x, idx n) noexcept
 Scalar sum: return sum x[i].
 
template<std::floating_point T>
NUM_K_AINLINE void 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 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 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 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).
 

Function Documentation

◆ axpby()

template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::axpby ( T *NUM_K_RESTRICT  y,
const T *NUM_K_RESTRICT  x,
a,
b,
idx  n 
)
noexcept

y[i] = a*x[i] + b*y[i].

Definition at line 46 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::kernel::array::axpby().

◆ axpbyz()

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,
a,
b,
idx  n 
)
noexcept

z[i] = a*x[i] + b*y[i].

Definition at line 59 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::kernel::array::axpbyz(), and num::backends::seq::matadd().

◆ axpy()

template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::axpy ( T *NUM_K_RESTRICT  y,
const T *NUM_K_RESTRICT  x,
alpha,
idx  n 
)
noexcept

y[i] += alpha * x[i]

Definition at line 34 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::backends::seq::axpy().

◆ dot()

template<std::floating_point T>
NUM_K_AINLINE T num::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]

Definition at line 73 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::backends::seq::dot().

◆ ger()

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,
alpha,
idx  m,
idx  n 
)
noexcept

Rank-1 update: A[i*n + j] += alpha * x[i] * y[j] (m x n row-major)

Inner loop over j is independent and vectorizable.

Definition at line 160 of file raw.hpp.

References NUM_K_IVDEP, and NUM_K_RESTRICT.

Referenced by num::kernel::dense::ger().

◆ l1_norm()

template<std::floating_point T>
NUM_K_AINLINE T num::kernel::raw::l1_norm ( const T *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

L1 norm: sum |x[i]|.

Definition at line 103 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::kernel::reduce::l1_norm().

◆ linf_norm()

template<std::floating_point T>
NUM_K_AINLINE T num::kernel::raw::linf_norm ( const T *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

L-infinity norm: max |x[i]|.

Definition at line 114 of file raw.hpp.

Referenced by num::kernel::reduce::linf_norm().

◆ matvec()

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)

y must be pre-allocated with size m. y and x must not alias A.

Definition at line 140 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::backends::seq::matvec().

◆ norm()

template<std::floating_point T>
NUM_K_AINLINE T num::kernel::raw::norm ( const T *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

Euclidean norm: sqrt(sum x[i]^2)

Definition at line 97 of file raw.hpp.

References norm_sq().

Referenced by num::backends::seq::norm().

◆ norm_sq()

template<std::floating_point T>
NUM_K_AINLINE T num::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)

Definition at line 86 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by norm().

◆ scale()

template<std::floating_point T>
NUM_K_AINLINE void num::kernel::raw::scale ( T *NUM_K_RESTRICT  x,
alpha,
idx  n 
)
noexcept

x[i] *= alpha

Definition at line 25 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::backends::seq::scale().

◆ sum()

template<std::floating_point T>
NUM_K_AINLINE T num::kernel::raw::sum ( const T *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

Scalar sum: return sum x[i].

Definition at line 127 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by num::kernel::reduce::sum().

◆ trsv_lower()

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).

x must be pre-allocated with size n. b and x must not alias each other.

Definition at line 181 of file raw.hpp.

Referenced by num::kernel::dense::trsv_lower().

◆ trsv_upper()

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).

x must be pre-allocated with size n. b and x must not alias each other.

Definition at line 200 of file raw.hpp.

Referenced by num::kernel::dense::trsv_upper().