asum2 (Descriptive Statistics)


Import

#include <archr/stats/asum2.h>
#include <archr/stats/asum2.hpp>
import archr.stats
atomsLoads('archr')

Synopsis

 float archr_stats_asum2_f32(const float *first, size_t nbelem);
(1)
 double archr_stats_asum2_f64(const double *first, size_t nbelem);
(2)
 float asum2(const float *first, size_t nbelem);
(1)
 double asum2(const double *first, size_t nbelem);
(2)
 float asum2(const float *first, const float *last);
(3)
 double asum2(const double *first, const double *last);
(4)
template <typename Range> typename Range::value_type asum2(const Range& data);
(5)
subroutine archr_stats_asum2_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(1)
subroutine archr_stats_asum2_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(2)
def asum2(first):
    return r
(1)
function r = archr_stats_asum2(first)
(1)

Description

This function computes the sum of the squared absolute value of elements stored in:

Parameters

first

the beginning of the range of elements to sum.

last

the end of the range of elements to sum.

nbelem

the number of elements to sum.

Return value

The sum of the squared absolute elements in the given range or container.

Example

#include <archr/stats/asum2.h>
#include <stdio.h>

int main()
{
  float v[] = {1,-2,3,-4,-5,6};

  printf("asum2(1,-2,3,-4,-5,6) = %f\n", archr_stats_asum2_f32(&v[0],6) );

  return 0;
}

Possible Output

asum2(1,-2,3,-4,-5,6) = 91.000000
asum2(1,-2,3,-4)     = 30.000000
#include <archr/stats/asum2.hpp>
#include <iostream>
#include <vector>

int main()
{
 std::vector<float> v{1,-2,-3,-4,5,-6};

 std::cout << "asum2(1,-2,-3,-4,5,-6) = " << archr::stats::asum2(v) << "\n";
 std::cout << "asum2(1,-2,-3,-4,5)    = " << archr::stats::asum2(v.data(), 5) << "\n";
 std::cout << "asum2(1,-2,-3,-4)      = " << archr::stats::asum2(v.data(), v.data() + 4) << "\n";

  return 0;
}

Possible Output

asum2(1,-2,-3,-4,5,-6) = 91
asum2(1,-2,-3,-4,5)    = 55
asum2(1,-2,-3,-4)      = 30

Possible Output