Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

VEC_$IMAX16                       Domain/OS                        VEC_$IMAX16


NAME
     vec_$imax16 - find the maximum absolute value in a 16-bit integer vector

SYNOPSIS (C)
     #include <apollo/base.h>
     #include <apollo/vec.h>

     void vec_$imax16(
          short *vector,
          long int &length,
          short *result,
          long int *location)

SYNOPSIS (Pascal)
     %include '/sys/ins/base.ins.pas';
     %include '/sys/ins/vec.ins.pas';

     procedure vec_$imax16(
          in vector: univ vec_$integer16_vector;
          in length: integer32;
          out result: integer16;
          out location: integer32);

SYNOPSIS (FORTRAN)
     %include '/sys/ins/base.ins.ftn'
     %include '/sys/ins/vec.ins.ftn'

           parameter (nvec = 10)

           integer*2 vector(nvec), result
           integer*4 length, location

           call vec_$imax16(vector, length, result, location)

DESCRIPTION
     Vec_$imax16 searches through length elements of vector and supplies the
     value and location of the element with the greatest absolute value.

     In C, the resulting operation is

          result = (short)abs(vector[0]);
          location = 1;
          for (i = 1; i < length; ++i)
               if ((short)abs(vector[i]) > result) {
                    location = i + 1;
                    result = (short)abs(vector[i]);
               }

     In Pascal, the resulting operation is

          result := abs(vector[1]);
          location = 1;
          for 10 i := 2 to length do
               if (abs(vector[i]) > result) then
                    begin
                    location := i;
                    result := abs(vector[i]);
                    end

     In FORTRAN, the resulting operation is

           result = iabs(vector(1))
           location = 1
           do 10 i = 2, length
               if (iabs(vector(i)) .gt. result) then
                    location = i
                    result = iabs(vector(i))
               endif
       10  continue

     vector
          The vector 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_$imax16 searches a row vector; whereas in FORTRAN,
     it searches a column vector.

SEE ALSO
     vec_$dmax, vec_$imax, vec_$imax16_i, vec_$max.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026