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

Functions

NUM_K_AINLINE void scale (real *NUM_K_RESTRICT x, real alpha, idx n) noexcept
 x[i] *= alpha
 
NUM_K_AINLINE void axpy (real *NUM_K_RESTRICT y, const real *NUM_K_RESTRICT x, real alpha, idx n) noexcept
 y[i] += alpha * x[i]
 
NUM_K_AINLINE void axpby (real *NUM_K_RESTRICT y, const real *NUM_K_RESTRICT x, real a, real b, idx n) noexcept
 y[i] = a*x[i] + b*y[i] (fused scale-and-add, one memory pass)
 
NUM_K_AINLINE void axpbyz (real *NUM_K_RESTRICT z, const real *NUM_K_RESTRICT x, const real *NUM_K_RESTRICT y, real a, real b, idx n) noexcept
 z[i] = a*x[i] + b*y[i] (fused, three-array, one pass each)
 
NUM_K_AINLINE real dot (const real *NUM_K_RESTRICT x, const real *NUM_K_RESTRICT y, idx n) noexcept
 dot product: return sum x[i] * y[i]
 
NUM_K_AINLINE real norm_sq (const real *NUM_K_RESTRICT x, idx n) noexcept
 sum x[i]^2 (no sqrt; use for convergence checks to avoid sqrt cost)
 
NUM_K_AINLINE real norm (const real *NUM_K_RESTRICT x, idx n) noexcept
 Euclidean norm: sqrt(sum x[i]^2)
 
NUM_K_AINLINE real l1_norm (const real *NUM_K_RESTRICT x, idx n) noexcept
 L1 norm: sum |x[i]|.
 
NUM_K_AINLINE real linf_norm (const real *NUM_K_RESTRICT x, idx n) noexcept
 L-infinity norm: max |x[i]|.
 
NUM_K_AINLINE real sum (const real *NUM_K_RESTRICT x, idx n) noexcept
 Scalar sum: return sum x[i].
 
NUM_K_AINLINE void matvec (real *NUM_K_RESTRICT y, const real *NUM_K_RESTRICT A, const real *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)
 
NUM_K_AINLINE void ger (real *NUM_K_RESTRICT A, const real *NUM_K_RESTRICT x, const real *NUM_K_RESTRICT y, real alpha, idx m, idx n) noexcept
 Rank-1 update: A[i*n + j] += alpha * x[i] * y[j] (m x n row-major)
 
NUM_K_AINLINE void trsv_lower (real *NUM_K_RESTRICT x, const real *NUM_K_RESTRICT L, const real *NUM_K_RESTRICT b, idx n) noexcept
 Forward substitution: solve Lx = b, L lower triangular (n x n, row-major).
 
NUM_K_AINLINE void trsv_upper (real *NUM_K_RESTRICT x, const real *NUM_K_RESTRICT U, const real *NUM_K_RESTRICT b, idx n) noexcept
 Back substitution: solve Ux = b, U upper triangular (n x n, row-major).
 

Function Documentation

◆ axpby()

NUM_K_AINLINE void num::kernel::raw::axpby ( real *NUM_K_RESTRICT  y,
const real *NUM_K_RESTRICT  x,
real  a,
real  b,
idx  n 
)
noexcept

y[i] = a*x[i] + b*y[i] (fused scale-and-add, one memory pass)

No direct BLAS equivalent. Avoids a separate scale pass then axpy pass: compared to scale(y,b); axpy(a,x,y), this reads y only once.

Definition at line 113 of file raw.hpp.

References NUM_K_IVDEP.

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

◆ axpbyz()

NUM_K_AINLINE void num::kernel::raw::axpbyz ( real *NUM_K_RESTRICT  z,
const real *NUM_K_RESTRICT  x,
const real *NUM_K_RESTRICT  y,
real  a,
real  b,
idx  n 
)
noexcept

z[i] = a*x[i] + b*y[i] (fused, three-array, one pass each)

No direct BLAS equivalent. z may alias x or y; otherwise fully independent.

Definition at line 125 of file raw.hpp.

References NUM_K_IVDEP.

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

◆ axpy()

NUM_K_AINLINE void num::kernel::raw::axpy ( real *NUM_K_RESTRICT  y,
const real *NUM_K_RESTRICT  x,
real  alpha,
idx  n 
)
noexcept

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

Definition at line 96 of file raw.hpp.

References NUM_K_IVDEP.

◆ dot()

NUM_K_AINLINE real num::kernel::raw::dot ( const real *NUM_K_RESTRICT  x,
const real *NUM_K_RESTRICT  y,
idx  n 
)
noexcept

dot product: return sum x[i] * y[i]

Definition at line 137 of file raw.hpp.

References NUM_K_IVDEP.

◆ ger()

NUM_K_AINLINE void num::kernel::raw::ger ( real *NUM_K_RESTRICT  A,
const real *NUM_K_RESTRICT  x,
const real *NUM_K_RESTRICT  y,
real  alpha,
idx  m,
idx  n 
)
noexcept

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

BLAS dger equivalent. Inner loop over j is independent and vectorizable.

Definition at line 254 of file raw.hpp.

References NUM_K_IVDEP, and NUM_K_RESTRICT.

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

◆ l1_norm()

NUM_K_AINLINE real num::kernel::raw::l1_norm ( const real *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

L1 norm: sum |x[i]|.

Definition at line 174 of file raw.hpp.

References NUM_K_IVDEP.

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

◆ linf_norm()

NUM_K_AINLINE real num::kernel::raw::linf_norm ( const real *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

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

Definition at line 189 of file raw.hpp.

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

◆ matvec()

NUM_K_AINLINE void num::kernel::raw::matvec ( real *NUM_K_RESTRICT  y,
const real *NUM_K_RESTRICT  A,
const real *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 227 of file raw.hpp.

References NUM_K_IVDEP.

◆ norm()

NUM_K_AINLINE real num::kernel::raw::norm ( const real *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

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

Definition at line 164 of file raw.hpp.

References norm_sq().

◆ norm_sq()

NUM_K_AINLINE real num::kernel::raw::norm_sq ( const real *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

sum x[i]^2 (no sqrt; use for convergence checks to avoid sqrt cost)

Definition at line 153 of file raw.hpp.

References NUM_K_IVDEP.

Referenced by norm().

◆ scale()

NUM_K_AINLINE void num::kernel::raw::scale ( real *NUM_K_RESTRICT  x,
real  alpha,
idx  n 
)
noexcept

x[i] *= alpha

Definition at line 83 of file raw.hpp.

References NUM_K_IVDEP.

◆ sum()

NUM_K_AINLINE real num::kernel::raw::sum ( const real *NUM_K_RESTRICT  x,
idx  n 
)
noexcept

Scalar sum: return sum x[i].

No BLAS equivalent (cblas_dasum sums absolute values; this does not).

Definition at line 210 of file raw.hpp.

References NUM_K_IVDEP.

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

◆ trsv_lower()

NUM_K_AINLINE void num::kernel::raw::trsv_lower ( real *NUM_K_RESTRICT  x,
const real *NUM_K_RESTRICT  L,
const real *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. Uses BLAS dtrsv when available (copies b -> x first, then solves in-place).

Definition at line 280 of file raw.hpp.

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

◆ trsv_upper()

NUM_K_AINLINE void num::kernel::raw::trsv_upper ( real *NUM_K_RESTRICT  x,
const real *NUM_K_RESTRICT  U,
const real *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. Uses BLAS dtrsv when available (copies b -> x first, then solves in-place).

Definition at line 305 of file raw.hpp.

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