10 inline double recursive_sum(
float t) {
return t; }
11 inline double recursive_sum(
double t) {
return t; }
14 inline auto recursive_sum(
const T& t) {
15 return std::accumulate(
16 begin(t), end(t), 0.0, [](
const auto& a,
const auto& b) {
17 return a + recursive_sum(b);
22 inline auto count(
const T& t) {
23 return std::accumulate(
24 begin(t), end(t), 0u, [](
const auto& a,
const auto& b) {
29 template <
typename T,
typename Allocator>
30 inline auto count(
const std::vector<T, Allocator>& coll) {
35 inline auto mean(
const T& t) {
36 return recursive_sum(t) / count(t);
39 inline double max_mag(
float t) {
return std::fabs(t); }
40 inline double max_mag(
double t) {
return std::fabs(t); }
43 inline auto max_mag(
const T& t) {
44 return std::accumulate(begin(t), end(t), 0.0, [](
double a,
auto b) {
45 return std::max(a, max_mag(b));
50 inline void mul(
float& ret,
double f) { ret *= f; }
51 inline void mul(
double& ret,
double f) { ret *= f; }
55 inline void mul(T& ret,
double f) {
64 inline void normalize(T& ret) {
65 if (
const auto mag = max_mag(ret)) {
71 inline void kernel_normalize(T& ret) {
72 const auto sum = std::abs(std::accumulate(begin(ret), end(ret), 0.0));
75 1.0 / sum - std::numeric_limits<typename T::value_type>::epsilon());
Definition: capsule_base.h:9