# asum (Descriptive Statistics) 1.x.x.x

### Import

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

### Synopsis

  float archr_stats_asum_f32(const float *first, size_t nbelem);  (1)  double archr_stats_asum_f64(const double *first, size_t nbelem);  (2)
  float asum(const float *first, size_t nbelem);  (1)  double asum(const double *first, size_t nbelem);  (2)  float asum(const float *first, const float *last);  (3)  double asum(const double *first, const double *last);  (4) template typename Range::value_type asum(const Range& data);  (5)
 subroutine archr_stats_asum_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)  (1) subroutine archr_stats_asum_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)  (2)
 def asum(first): return r  (1)
 function r = archr_stats_asum(first)  (1)

### Description

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

• (1,2) the [first, last[ range
• (3,4) the [first, first+nbelem[ range

### 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 absolute elements in the given range or container.

### Example

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

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

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

return 0;
}


### Possible Output

asum(1,-2,3,-4,-5,6) = 21.000000
asum(1,-2,3,-4)     = 10.000000

#include <archr/stats/asum.hpp>
#include <iostream>
#include <vector>

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

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

return 0;
}


### Possible Output

asum(1,-2,-3,-4,5,-6) = 21
asum(1,-2,-3,-4,5)    = 15
asum(1,-2,-3,-4)      = 10