VEC_$SUM Domain/OS VEC_$SUM
NAME
vec_$sum - sum the elements of a single-precision vector
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
float vec_$sum(
float *vec,
long int &length)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
function vec_$sum(
in vec: univ vec_$real_vector;
in length: integer32): real;
SYNOPSIS (FORTRAN)
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/vec.ins.ftn'
parameter (nvec = 10)
real vec(nvec), sum
integer*4 length
sum = vec_$sum(vec, length)
DESCRIPTION
Vec_$sum adds together length elements of the single-precision array vec-
tor and returns the sum.
In C, the resulting operation is
return_value = 0.0;
for (i = 0; i < length; ++i)
return_value += vec[i];
In Pascal, the resulting operation is
return_value := 0.0;
for i := 1 to length do
return_value := return_value + vec[i];
In FORTRAN, the resulting operation is
vec_$sum = 0.0
do 10 i = 1, length
vec_$sum = vec_$sum + vec(i)
10 continue
vec The vector to sum.
length
The number of elements in vec to sum.
NOTES
When vec_$sum is used to operate on matrixes in C and Pascal, vec is a
row vector; whereas in FORTRAN, it is a column vector.
SEE ALSO
vec_$dsum, vec_$isum, vec_$isum16, vec_$sum_i.