VEC_$MAX_I Domain/OS VEC_$MAX_I
NAME
vec_$max_i - find the maximum absolute value in a vector from a single-
precision matrix
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
void vec_$max_i(
float *vector,
long int &inc,
long int &length,
float *result,
long int *location)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
procedure vec_$max_i(
in vector: univ vec_$real_vector;
in inc: integer32;
in length: integer32;
out result: real;
out location: integer32);
SYNOPSIS (FORTRAN)
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/vec.ins.ftn'
parameter (nvec = 10)
real vector(nvec), result
integer*4 length, inc, location
call vec_$max_i(vector, inc, length, result, location)
DESCRIPTION
Vec_$max_i searches through the length elements of vector selected by
inc, and supplies the value and location of the element with the greatest
absolute value.
Through appropriate choice of inc, a program can use vec_$max_i to search
a vector within a matrix. To search the Mth vector in a matrix, choose
inc equal to the number of vectors in the matrix, and place the Mth ele-
ment of the matrix array at the beginning of vector.
In C, the resulting operation is
result = (float)fabs(vector[0]);
location = 1;
j = inc;
for (i = 1; i < length, ++i) {
if ((float)fabs(vector[j]) > result) {
location = i + 1;
result = (float)fabs(vector[j]);
}
j += inc;
}
In Pascal, the resulting operation is
result := abs(vector[1]);
location := 1;
j := 1 + inc;
for 10 i := 2 to length do
begin
if (abs(vector[j]) > result) then
begin
location := i;
result := abs(vector[j]);
end
j := j + inc;
end
In FORTRAN, the resulting operation is
result = abs(vector(1))
location = 1
j = 1 + inc
do 10 i = 2, length
if (abs(vector(j)) .gt. result) then
location = i
result = abs(vector(j))
endif
j = j + inc
10 continue
vector
The array to search.
inc An increment for the index of vector that selects the elements to
search.
length
The number of elements to search.
result
The maximum absolute value of all the elements searched.
location
The location of the element with the greatest absolute value. The
location supplied in location is just the index of the element with
the greatest absolute value in FORTRAN or Pascal (if vector is
declared to begin with index 1). In C, location - 1 is the index of
the element.
NOTES
In C and Pascal, vec_$max_i searches a column vector; whereas in FORTRAN,
it searches a row vector.
SEE ALSO
vec_$dmax_i, vec_$imax16_i, vec_$imax_i, vec_$max.