zlaqhp.c
Go to the documentation of this file.
00001 /* zlaqhp.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 /* Subroutine */ int zlaqhp_(char *uplo, integer *n, doublecomplex *ap, 
00017         doublereal *s, doublereal *scond, doublereal *amax, char *equed)
00018 {
00019     /* System generated locals */
00020     integer i__1, i__2, i__3, i__4;
00021     doublereal d__1;
00022     doublecomplex z__1;
00023 
00024     /* Local variables */
00025     integer i__, j, jc;
00026     doublereal cj, large;
00027     extern logical lsame_(char *, char *);
00028     doublereal small;
00029     extern doublereal dlamch_(char *);
00030 
00031 
00032 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00033 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00034 /*     November 2006 */
00035 
00036 /*     .. Scalar Arguments .. */
00037 /*     .. */
00038 /*     .. Array Arguments .. */
00039 /*     .. */
00040 
00041 /*  Purpose */
00042 /*  ======= */
00043 
00044 /*  ZLAQHP equilibrates a Hermitian matrix A using the scaling factors */
00045 /*  in the vector S. */
00046 
00047 /*  Arguments */
00048 /*  ========= */
00049 
00050 /*  UPLO    (input) CHARACTER*1 */
00051 /*          Specifies whether the upper or lower triangular part of the */
00052 /*          Hermitian matrix A is stored. */
00053 /*          = 'U':  Upper triangular */
00054 /*          = 'L':  Lower triangular */
00055 
00056 /*  N       (input) INTEGER */
00057 /*          The order of the matrix A.  N >= 0. */
00058 
00059 /*  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00060 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00061 /*          A, packed columnwise in a linear array.  The j-th column of A */
00062 /*          is stored in the array AP as follows: */
00063 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00064 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00065 
00066 /*          On exit, the equilibrated matrix:  diag(S) * A * diag(S), in */
00067 /*          the same storage format as A. */
00068 
00069 /*  S       (input) DOUBLE PRECISION array, dimension (N) */
00070 /*          The scale factors for A. */
00071 
00072 /*  SCOND   (input) DOUBLE PRECISION */
00073 /*          Ratio of the smallest S(i) to the largest S(i). */
00074 
00075 /*  AMAX    (input) DOUBLE PRECISION */
00076 /*          Absolute value of largest matrix entry. */
00077 
00078 /*  EQUED   (output) CHARACTER*1 */
00079 /*          Specifies whether or not equilibration was done. */
00080 /*          = 'N':  No equilibration. */
00081 /*          = 'Y':  Equilibration was done, i.e., A has been replaced by */
00082 /*                  diag(S) * A * diag(S). */
00083 
00084 /*  Internal Parameters */
00085 /*  =================== */
00086 
00087 /*  THRESH is a threshold value used to decide if scaling should be done */
00088 /*  based on the ratio of the scaling factors.  If SCOND < THRESH, */
00089 /*  scaling is done. */
00090 
00091 /*  LARGE and SMALL are threshold values used to decide if scaling should */
00092 /*  be done based on the absolute size of the largest matrix element. */
00093 /*  If AMAX > LARGE or AMAX < SMALL, scaling is done. */
00094 
00095 /*  ===================================================================== */
00096 
00097 /*     .. Parameters .. */
00098 /*     .. */
00099 /*     .. Local Scalars .. */
00100 /*     .. */
00101 /*     .. External Functions .. */
00102 /*     .. */
00103 /*     .. Intrinsic Functions .. */
00104 /*     .. */
00105 /*     .. Executable Statements .. */
00106 
00107 /*     Quick return if possible */
00108 
00109     /* Parameter adjustments */
00110     --s;
00111     --ap;
00112 
00113     /* Function Body */
00114     if (*n <= 0) {
00115         *(unsigned char *)equed = 'N';
00116         return 0;
00117     }
00118 
00119 /*     Initialize LARGE and SMALL. */
00120 
00121     small = dlamch_("Safe minimum") / dlamch_("Precision");
00122     large = 1. / small;
00123 
00124     if (*scond >= .1 && *amax >= small && *amax <= large) {
00125 
00126 /*        No equilibration */
00127 
00128         *(unsigned char *)equed = 'N';
00129     } else {
00130 
00131 /*        Replace A by diag(S) * A * diag(S). */
00132 
00133         if (lsame_(uplo, "U")) {
00134 
00135 /*           Upper triangle of A is stored. */
00136 
00137             jc = 1;
00138             i__1 = *n;
00139             for (j = 1; j <= i__1; ++j) {
00140                 cj = s[j];
00141                 i__2 = j - 1;
00142                 for (i__ = 1; i__ <= i__2; ++i__) {
00143                     i__3 = jc + i__ - 1;
00144                     d__1 = cj * s[i__];
00145                     i__4 = jc + i__ - 1;
00146                     z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i;
00147                     ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00148 /* L10: */
00149                 }
00150                 i__2 = jc + j - 1;
00151                 i__3 = jc + j - 1;
00152                 d__1 = cj * cj * ap[i__3].r;
00153                 ap[i__2].r = d__1, ap[i__2].i = 0.;
00154                 jc += j;
00155 /* L20: */
00156             }
00157         } else {
00158 
00159 /*           Lower triangle of A is stored. */
00160 
00161             jc = 1;
00162             i__1 = *n;
00163             for (j = 1; j <= i__1; ++j) {
00164                 cj = s[j];
00165                 i__2 = jc;
00166                 i__3 = jc;
00167                 d__1 = cj * cj * ap[i__3].r;
00168                 ap[i__2].r = d__1, ap[i__2].i = 0.;
00169                 i__2 = *n;
00170                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00171                     i__3 = jc + i__ - j;
00172                     d__1 = cj * s[i__];
00173                     i__4 = jc + i__ - j;
00174                     z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i;
00175                     ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00176 /* L30: */
00177                 }
00178                 jc = jc + *n - j + 1;
00179 /* L40: */
00180             }
00181         }
00182         *(unsigned char *)equed = 'Y';
00183     }
00184 
00185     return 0;
00186 
00187 /*     End of ZLAQHP */
00188 
00189 } /* zlaqhp_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:41