idamax.c
Go to the documentation of this file.
00001 /* idamax.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 integer idamax_(integer *n, doublereal *dx, integer *incx)
00017 {
00018     /* System generated locals */
00019     integer ret_val, i__1;
00020     doublereal d__1;
00021 
00022     /* Local variables */
00023     integer i__, ix;
00024     doublereal dmax__;
00025 
00026 /*     .. Scalar Arguments .. */
00027 /*     .. */
00028 /*     .. Array Arguments .. */
00029 /*     .. */
00030 
00031 /*  Purpose */
00032 /*  ======= */
00033 
00034 /*     finds the index of element having max. absolute value. */
00035 /*     jack dongarra, linpack, 3/11/78. */
00036 /*     modified 3/93 to return if incx .le. 0. */
00037 /*     modified 12/3/93, array(1) declarations changed to array(*) */
00038 
00039 
00040 /*     .. Local Scalars .. */
00041 /*     .. */
00042 /*     .. Intrinsic Functions .. */
00043 /*     .. */
00044     /* Parameter adjustments */
00045     --dx;
00046 
00047     /* Function Body */
00048     ret_val = 0;
00049     if (*n < 1 || *incx <= 0) {
00050         return ret_val;
00051     }
00052     ret_val = 1;
00053     if (*n == 1) {
00054         return ret_val;
00055     }
00056     if (*incx == 1) {
00057         goto L20;
00058     }
00059 
00060 /*        code for increment not equal to 1 */
00061 
00062     ix = 1;
00063     dmax__ = abs(dx[1]);
00064     ix += *incx;
00065     i__1 = *n;
00066     for (i__ = 2; i__ <= i__1; ++i__) {
00067         if ((d__1 = dx[ix], abs(d__1)) <= dmax__) {
00068             goto L5;
00069         }
00070         ret_val = i__;
00071         dmax__ = (d__1 = dx[ix], abs(d__1));
00072 L5:
00073         ix += *incx;
00074 /* L10: */
00075     }
00076     return ret_val;
00077 
00078 /*        code for increment equal to 1 */
00079 
00080 L20:
00081     dmax__ = abs(dx[1]);
00082     i__1 = *n;
00083     for (i__ = 2; i__ <= i__1; ++i__) {
00084         if ((d__1 = dx[i__], abs(d__1)) <= dmax__) {
00085             goto L30;
00086         }
00087         ret_val = i__;
00088         dmax__ = (d__1 = dx[i__], abs(d__1));
00089 L30:
00090         ;
00091     }
00092     return ret_val;
00093 } /* idamax_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:50