VEC_$SUM_I Domain/OS VEC_$SUM_I
NAME
vec_$sum_i - sum the elements of a vector in a single-precision matrix
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
float vec_$sum_i(
float *vec,
long int &inc,
long int &length)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
function vec_$sum_i(
in vec: univ vec_$real_vector;
in inc: integer32;
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, inc
sum = vec_$sum_i(vec, inc, length)
DESCRIPTION
Vec_$sum_i adds length elements from the single-precision array vector
selected by inc and returns the sum.
Through appropriate choice of inc, a program can use vec_$sum_i to sum an
individual vector in a matrix. To sum the Mth vector in a matrix, choose
inc equal to the number of vectors in the matrix.
In C, the resulting operation is
return_value = 0.0;
j = 0;
for (i = 0; i < length; ++i) {
return_value += vec[j];
j += inc;
}
In Pascal, the resulting operation is
return_value := 0.0;
j := 1;
for i := 1 to length do
begin
return_value := return_value + vec[j];
j := j + inc;
end
In FORTRAN, the resulting operation is
vec_$sum_i = 0.0
j = 1
do 10 i = 1, length
vec_$sum_i = vec_$sum_i + vec(j)
j = j + inc
10 continue
vec An array that contains the elements to sum.
inc An increment for the index of vec that selects which elements of vec
are summed.
length
The number of elements in vec to sum.
NOTES
In C and Pascal, vec_$sum_i sums a column vector; whereas in FORTRAN, it
sums a row vector.
SEE ALSO
vec_$dsum_i, vec_$isum16_i, vec_$isum_i, vec_$sum.