VEC_$DMAX_I Domain/OS VEC_$DMAX_I
NAME
vec_$dmax_i - find the maximum absolute value in a vector from a double-
precision matrix
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
void vec_$dmax_i(
double *vector,
long int &inc,
long int &length,
double *result,
long int *location)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
procedure vec_$dmax_i(
in vector: univ vec_$double_vector;
in inc: integer32;
in length: integer32;
out result: double;
out location: integer32);
SYNOPSIS (FORTRAN)
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/vec.ins.ftn'
parameter (nvec = 10)
double precision vector(nvec), result
integer*4 length, inc, location
call vec_$dmax_i(vector, inc, length, result, location)
DESCRIPTION
Vec_$dmax_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_$dmax_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 element of the matrix array at the beginning of vector.
In C, the resulting operation is
result = fabs(vector[0]);
location = 1;
j = inc;
for (i = 1; i < length, ++i) {
if (fabs(vector[j]) > result) {
location = i + 1;
result = 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 = dabs(vector(1))
location = 1
j = 1 + inc
do 10 i = 2, length
if (dabs(vector(j)) .gt. result) then
location = i
result = dabs(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_$dmax_i searches a column vector; whereas in FOR-
TRAN, it searches a row vector.
SEE ALSO
vec_$dmax, vec_$imax16_i, vec_$imax_i, vec_$max_i.