VEC_$ISUM16_I Domain/OS VEC_$ISUM16_I
NAME
vec_$isum16_i - sum the elements of a vector in a 16-bit integer matrix
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
short vec_$isum16_i(
short *vec,
long int &inc,
long int &length)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
function vec_$isum16_i(
in vec: univ vec_$integer16_vector;
in inc: integer32;
in length: integer32): integer16;
SYNOPSIS (FORTRAN)
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/vec.ins.ftn'
parameter (nvec = 10)
integer*2 vec(nvec), sum
integer*4 length, inc
sum = vec_$isum16_i(vec, inc, length)
DESCRIPTION
Vec_$isum16_i adds length elements from the 16-bit integer array vector
selected by inc and returns the sum.
Through appropriate choice of inc, a program can use vec_$isum16_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;
j = 0;
for (i = 0; i < length; ++i) {
return_value += vec[j];
j += inc;
}
In Pascal, the resulting operation is
return_value := 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_$isum16_i = 0
j = 1
do 10 i = 1, length
vec_$isum16_i = vec_$isum16_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_$isum16_i sums a column vector; whereas in FORTRAN,
it sums a row vector.
SEE ALSO
vec_$dsum_i, vec_$isum16, vec_$isum_i, vec_$sum_i.