NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
11-numcxx-ref.cxx

Working with arrays, numcxx style with references

#include <cstdio>
// initialize vector x with some data
{
const int n=X.size();
for (int i=0;i<n;i++) X(i)= 1.0/(double)(1+n-i);
}
// calculate the sum of the elements of x
{
double sum=0;
for (int i=0;i<X.size();i++)sum+=X(i);
return sum;
}
int main()
{
const int n=12345678;
// call constructor
double s=sum_elements(X);
printf("sum=%e\n",s);
}