VEC_$DSUM_I Domain/OS VEC_$DSUM_I
NAME
vec_$dsum_i - sum the elements of a vector in a double-precision matrix
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
double vec_$dsum_i(
double *vec,
long int &inc,
long int &length)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
function vec_$dsum_i(
in vec: univ vec_$double_vector;
in inc: integer32;
in length: integer32): double;
SYNOPSIS (FORTRAN)
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/vec.ins.ftn'
parameter (nvec = 10)
double precision vec(nvec), sum
integer*4 length, inc
sum = vec_$sum_i(vec, inc, length)
DESCRIPTION
Vec_$dsum_i adds length elements from the double-precision array vector
selected by inc and returns the sum.
Through appropriate choice of inc, a program can use vec_$dsum_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_$dsum_i = 0.0
j = 1
do 10 i = 1, length
vec_$dsum_i = vec_$dsum_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_$dsum_i sums a column vector; whereas in FORTRAN, it
sums a row vector.
SEE ALSO
vec_$dsum, vec_$isum16_i, vec_$isum_i, vec_$sum_i.