SAMIN(3dxml) — Subroutines
Name
samin, damin, scamin, dzamin − Minimum absolute value
FORMAT
{S,D}AMIN (n, x, incx) SCAMIN (n, x, incx) DZAMIN (n, x, incx)
Function Value
aminreal∗4 | real∗8
The element of the vector x with the smallest absolute value.
If n<=0, amin = 0.
Arguments
ninteger∗4
On entry, the number of elements in the vector x.
On exit, n is unchanged.
xreal∗4 | real∗8 | complex∗8 | complex∗16
On entry, a one-dimensional array X of length at least (1+(n-1)∗|incx|), containing the elements of the vector x.
On exit, x is unchanged.
incxinteger∗4
On entry, the increment for the array X.
If incx > 0, vector x is stored forward in the array, so that x(i) is stored in location X(1+(i-1)∗incx).
If incx < 0, vector x is stored backward in the array, so that x(i) is stored in location X(1+(n-i)∗|incx|).
If incx = 0, only the first element is accessed.
On exit, incx is unchanged.
Description
These functions determine the smallest absolute value of the elements of a vector x: MAX{|x(j)|, j = 1,2, ..., n}
For complex vectors, each element x(j) is a complex number. In this subprogram, the absolute value of a complex number is defined as the absolute value of the real part of the complex number plus the absolute value of the imaginary part of the complex number: |x(j)| = |a(j)| + |b(j)| = |(real)| + |(imaginary)|
If incx < 0, the result is identical to using |incx|. If incx = 0, the computation is a time-consuming way of setting amin = |x(1)|.
Example
INTEGER∗4 N, INCX
REAL∗4 X(400), AMIN
INCX = 3
N = 100
AMIN = SAMIN(N,X,INCX)
These FORTRAN examples show how to compute the element with the smallest absolute value.