LAPACK 3.3.1
Linear Algebra PACKage

idamax.f

Go to the documentation of this file.
00001       INTEGER FUNCTION IDAMAX(N,DX,INCX)
00002 *     .. Scalar Arguments ..
00003       INTEGER INCX,N
00004 *     ..
00005 *     .. Array Arguments ..
00006       DOUBLE PRECISION DX(*)
00007 *     ..
00008 *
00009 *  Purpose
00010 *  =======
00011 *
00012 *     IDAMAX finds the index of element having max. absolute value.
00013 *
00014 *  Further Details
00015 *  ===============
00016 *
00017 *     jack dongarra, linpack, 3/11/78.
00018 *     modified 3/93 to return if incx .le. 0.
00019 *     modified 12/3/93, array(1) declarations changed to array(*)
00020 *
00021 *  =====================================================================
00022 *
00023 *     .. Local Scalars ..
00024       DOUBLE PRECISION DMAX
00025       INTEGER I,IX
00026 *     ..
00027 *     .. Intrinsic Functions ..
00028       INTRINSIC DABS
00029 *     ..
00030       IDAMAX = 0
00031       IF (N.LT.1 .OR. INCX.LE.0) RETURN
00032       IDAMAX = 1
00033       IF (N.EQ.1) RETURN
00034       IF (INCX.EQ.1) THEN
00035 *
00036 *        code for increment equal to 1
00037 *
00038          DMAX = DABS(DX(1))
00039          DO I = 2,N
00040             IF (DABS(DX(I)).GT.DMAX) THEN
00041                IDAMAX = I
00042                DMAX = DABS(DX(I))
00043             END IF
00044          END DO
00045       ELSE
00046 *
00047 *        code for increment not equal to 1
00048 *
00049          IX = 1
00050          DMAX = DABS(DX(1))
00051          IX = IX + INCX
00052          DO I = 2,N
00053             IF (DABS(DX(IX)).GT.DMAX) THEN
00054                IDAMAX = I
00055                DMAX = DABS(DX(IX))
00056             END IF
00057             IX = IX + INCX
00058          END DO
00059       END IF
00060       RETURN
00061       END
 All Files Functions