12template <
class T,
class Abi,
StorageOrder O0,
class Tinit,
class F,
class R,
class... Args>
18 iter_elems<T, Abi, O0>([&](
auto... args) { init = fun(init, args...); }, x0, xs...);
22template <
class T,
class Abi, StorageOrder OA>
25 using norms = linalg::norms<T, simd>;
30template <
class T,
class Abi, StorageOrder OA, StorageOrder OB>
33 auto fma = [](
auto accum,
auto ai,
auto bi) {
return ai * bi + accum; };
34 auto simd_reduce = [](
auto accum) {
return reduce(accum); };
35 return reduce<T, Abi>(simd{0}, fma, simd_reduce, a, b);
39template <
class T,
class Abi, StorageOrder OA>
42 auto fma = [](
auto accum,
auto ai) {
return ai * ai + accum; };
43 auto simd_reduce = [](
auto accum) {
return reduce(accum); };
44 return reduce<T, Abi>(simd{0}, fma, simd_reduce, a);
48template <
class T,
class Abi, StorageOrder OW, StorageOrder OA>
51 auto wnd = [](
auto accum,
auto wi,
auto ai) {
return wi * (ai * ai) + accum; };
52 auto simd_reduce = [](
auto accum) {
return reduce(accum); };
53 return reduce<T, Abi>(simd{0}, wnd, simd_reduce, w, a);
57template <
class T,
class Abi, StorageOrder OW, StorageOrder OA, StorageOrder OB>
61 auto wnd = [](
auto accum,
auto wi,
auto ai,
auto bi) {
63 return wi * (ei * ei) + accum;
65 auto simd_reduce = [](
auto accum) {
return reduce(accum); };
66 return reduce<T, Abi>(simd{0}, wnd, simd_reduce, w, a, b);
80template <simdifiable Vx>
87template <simdifiable Vx>
89 return norms_all(std::forward<Vx>(x)).norm_inf();
93template <simdifiable Vx>
95 return norms_all(std::forward<Vx>(x)).norm_1();
99template <simdifiable Vx>
106template <simdifiable Vx>
113template <simdifiable Vx, simdifiable Vy>
122template <simdifiable Vw, simdifiable Va>
131template <simdifiable Vw, simdifiable Va, simdifiable Vb>
145inline namespace multi {
154template <simdifiable_multi Vx>
157 for (
index_t b = 0; b < x.num_batches(); ++b)
163template <simdifiable_multi Vx>
165 return norms_all(std::forward<Vx>(x)).norm_inf();
169template <simdifiable_multi Vx>
171 return norms_all(std::forward<Vx>(x)).norm_1();
175template <simdifiable_multi Vx>
178 for (
index_t b = 0; b < x.num_batches(); ++b)
184template <simdifiable_multi Vx>
191template <simdifiable_multi Vx, simdifiable_multi Vy>
196 for (
index_t b = 0; b < x.num_batches(); ++b)
202template <simdifiable_multi Vw, simdifiable_multi Vx>
207 for (
index_t b = 0; b < w.num_batches(); ++b)
213template <simdifiable_multi Vw, simdifiable_multi Vx, simdifiable_multi Vy>
219 for (
index_t b = 0; b < w.num_batches(); ++b)
simdified_value_t< Vx > norm_inf(Vx &&x)
Compute the infinity norm of a vector.
simdified_value_t< Vx > norm_2_squared(Vx &&x)
Compute the squared 2-norm of a vector.
simdified_value_t< Vx > norm_2(Vx &&x)
Compute the 2-norm of a vector.
simdified_value_t< Vx > norm_2(Vx &&x)
Compute the 2-norm of a vector.
simdified_value_t< Vx > norm_2_squared(Vx &&x)
Compute the squared 2-norm of a vector.
simdified_value_t< Vx > norm_1(Vx &&x)
Compute the 1-norm of a vector.
simdified_value_t< Vw > weighted_norm_sq(Vw &&w, Vx &&x)
∑ wᵢ xᵢ².
simdified_value_t< Vx > dot(Vx &&x, Vy &&y)
Compute the dot product of two vectors.
simdified_value_t< Vx > norm_1(Vx &&x)
Compute the 1-norm of a vector.
norms< simdified_value_t< Vx > >::result norms_all(Vx &&x)
Compute the norms (max, 1-norm, and 2-norm) of a vector.
simdified_value_t< Vw > weighted_norm_sq_difference(Vw &&w, Vx &&x, Vy &&y)
∑ wᵢ(xᵢ - yᵢ)².
simdified_value_t< Vx > norm_inf(Vx &&x)
Compute the infinity norm of a vector.
simdified_value_t< Vx > dot(Vx &&x, Vy &&y)
Compute the dot product of two vectors.
simdified_value_t< Vw > weighted_norm_sq(Vw &&w, Va &&a)
∑ wᵢ aᵢ².
simdified_value_t< Vw > weighted_norm_sq_diff(Vw &&w, Va &&a, Vb &&b)
∑ wᵢ(aᵢ - bᵢ)².
norms< simdified_value_t< Vx > >::result norms_all(Vx &&x)
Compute the norms (max, 1-norm, and 2-norm) of a vector.
#define GUANAQO_TRACE_LINALG(name, gflops)
stdx::simd< Tp, Abi > simd
typename detail::simdified_value< V >::type simdified_value_t
typename detail::simdified_abi< V >::type simdified_abi_t
constexpr bool simdify_compatible
constexpr auto simdify(simdifiable auto &&a) -> simdified_view_t< decltype(a)>
simd_view_types< std::remove_const_t< T >, Abi >::template view< T, Order > view
Utilities for computing vector norms.
static result_simd zero_simd()
typename norms< T >::result result
Accumulator.