LAPACK 3.3.0

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) GO TO 20
00035 *
00036 *        code for increment not equal to 1
00037 *
00038       IX = 1
00039       DMAX = DABS(DX(1))
00040       IX = IX + INCX
00041       DO 10 I = 2,N
00042           IF (DABS(DX(IX)).LE.DMAX) GO TO 5
00043           IDAMAX = I
00044           DMAX = DABS(DX(IX))
00045     5     IX = IX + INCX
00046    10 CONTINUE
00047       RETURN
00048 *
00049 *        code for increment equal to 1
00050 *
00051    20 DMAX = DABS(DX(1))
00052       DO 30 I = 2,N
00053           IF (DABS(DX(I)).LE.DMAX) GO TO 30
00054           IDAMAX = I
00055           DMAX = DABS(DX(I))
00056    30 CONTINUE
00057       RETURN
00058       END
 All Files Functions