|
numerics 0.1.0
|
Elementwise vector kernels (namespace num::kernel::array) More...
Go to the source code of this file.
Namespaces | |
| namespace | num |
| namespace | num::kernel |
| namespace | num::kernel::array |
Functions | |
| void | num::kernel::array::axpby (real a, const Vector &x, real b, Vector &y, seq_t) noexcept |
| Sequential: y[i] = a*x[i] + b*y[i] (single-pass; calls raw::axpby) | |
| void | num::kernel::array::axpby (real a, const Vector &x, real b, Vector &y, par_t) |
| Parallel: y[i] = a*x[i] + b*y[i] (OMP parallel-for; falls back to seq_t when NUMERICS_HAS_OMP is not defined) | |
| void | num::kernel::array::axpby (real a, const Vector &x, real b, Vector &y) |
| Default policy (par_t if OMP available, seq_t otherwise) | |
| void | num::kernel::array::axpbyz (real a, const Vector &x, real b, const Vector &y, Vector &z, seq_t) noexcept |
| Sequential: z[i] = a*x[i] + b*y[i] (single-pass; calls raw::axpbyz) | |
| void | num::kernel::array::axpbyz (real a, const Vector &x, real b, const Vector &y, Vector &z, par_t) |
| Parallel: z[i] = a*x[i] + b*y[i] (OMP parallel-for) | |
| void | num::kernel::array::axpbyz (real a, const Vector &x, real b, const Vector &y, Vector &z) |
| Default policy. | |
| template<typename F > | |
| void | num::kernel::array::map (Vector &x, F &&f) |
| In-place elementwise map: x[i] = f(x[i]) | |
| template<typename F > | |
| void | num::kernel::array::map (CVector &x, F &&f) |
| In-place elementwise map on CVector. | |
| template<typename T , typename F > | |
| void | num::kernel::array::zip_map (const BasicVector< T > &x, const BasicVector< T > &y, BasicVector< T > &z, F &&f) |
| Fused binary map: z[i] = f(x[i], y[i]) | |
| template<typename F > | |
| real | num::kernel::array::reduce (const Vector &x, real init, F &&f) |
| Single-pass left fold: f(f(f(init, x[0]), x[1]), ..., x[n-1]) | |
Elementwise vector kernels (namespace num::kernel::array)
All operations work element-by-element over a Vector. The central property is single-pass memory access: fused operations read each array once, avoiding redundant loads that separate calls would incur.
Dispatched operations (seq_t / par_t overloads + default): axpby(a, x, b, y) – y[i] = a*x[i] + b*y[i] (fused; no BLAS eq.) axpbyz(a, x, b, y, z) – z[i] = a*x[i] + b*y[i] (fused; no BLAS eq.)
Always-inline template operations (policy not needed; compiler sees body): map(x, f) – x[i] = f(x[i]) map(cx, f) – CVector variant zip_map(x, y, z, f) – z[i] = f(x[i], y[i]) reduce(x, init, f) – left fold over x
Include kernel/kernel.hpp to get all kernel sub-modules together.
Definition in file array.hpp.