~ubuntu-branches/ubuntu/lucid/igraph/lucid

« back to all changes in this revision

Viewing changes to src/lapack/dlanhs.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Malaterre
  • Date: 2009-11-16 18:12:42 UTC
  • Revision ID: james.westby@ubuntu.com-20091116181242-mzv9p5fz9uj57xd1
Tags: upstream-0.5.3
ImportĀ upstreamĀ versionĀ 0.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  -- translated by f2c (version 20050501).
 
2
   You must link the resulting object file with libf2c:
 
3
        on Microsoft Windows system, link with libf2c.lib;
 
4
        on Linux or Unix systems, link with .../path/to/libf2c.a -lm
 
5
        or, if you install libf2c.a in a standard place, with -lf2c -lm
 
6
        -- in that order, at the end of the command line, as in
 
7
                cc *.o -lf2c -lm
 
8
        Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
 
9
 
 
10
                http://www.netlib.org/f2c/libf2c.zip
 
11
*/
 
12
 
 
13
#include "config.h"
 
14
#include "arpack_internal.h"
 
15
#include "f2c.h"
 
16
 
 
17
/* Table of constant values */
 
18
 
 
19
static integer c__1 = 1;
 
20
 
 
21
doublereal igraphdlanhs_(char *norm, integer *n, doublereal *a, integer *lda, 
 
22
        doublereal *work)
 
23
{
 
24
    /* System generated locals */
 
25
    integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
 
26
    doublereal ret_val, d__1, d__2, d__3;
 
27
 
 
28
    /* Builtin functions */
 
29
    double sqrt(doublereal);
 
30
 
 
31
    /* Local variables */
 
32
    static integer i__, j;
 
33
    static doublereal sum, scale;
 
34
    extern logical igraphlsame_(char *, char *);
 
35
    static doublereal value;
 
36
    extern /* Subroutine */ int igraphdlassq_(integer *, doublereal *, integer *, 
 
37
            doublereal *, doublereal *);
 
38
 
 
39
 
 
40
/*  -- LAPACK auxiliary routine (version 3.0) -- */
 
41
/*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
 
42
/*     Courant Institute, Argonne National Lab, and Rice University */
 
43
/*     October 31, 1992 */
 
44
 
 
45
/*     .. Scalar Arguments .. */
 
46
/*     .. */
 
47
/*     .. Array Arguments .. */
 
48
/*     .. */
 
49
 
 
50
/*  Purpose */
 
51
/*  ======= */
 
52
 
 
53
/*  DLANHS  returns the value of the one norm,  or the Frobenius norm, or */
 
54
/*  the  infinity norm,  or the  element of  largest absolute value  of a */
 
55
/*  Hessenberg matrix A. */
 
56
 
 
57
/*  Description */
 
58
/*  =========== */
 
59
 
 
60
/*  DLANHS returns the value */
 
61
 
 
62
/*     DLANHS = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
 
63
/*              ( */
 
64
/*              ( norm1(A),         NORM = '1', 'O' or 'o' */
 
65
/*              ( */
 
66
/*              ( normI(A),         NORM = 'I' or 'i' */
 
67
/*              ( */
 
68
/*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
 
69
 
 
70
/*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
 
71
/*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
 
72
/*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
 
73
/*  squares).  Note that  max(abs(A(i,j)))  is not a  matrix norm. */
 
74
 
 
75
/*  Arguments */
 
76
/*  ========= */
 
77
 
 
78
/*  NORM    (input) CHARACTER*1 */
 
79
/*          Specifies the value to be returned in DLANHS as described */
 
80
/*          above. */
 
81
 
 
82
/*  N       (input) INTEGER */
 
83
/*          The order of the matrix A.  N >= 0.  When N = 0, DLANHS is */
 
84
/*          set to zero. */
 
85
 
 
86
/*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
 
87
/*          The n by n upper Hessenberg matrix A; the part of A below the */
 
88
/*          first sub-diagonal is not referenced. */
 
89
 
 
90
/*  LDA     (input) INTEGER */
 
91
/*          The leading dimension of the array A.  LDA >= max(N,1). */
 
92
 
 
93
/*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK), */
 
94
/*          where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
 
95
/*          referenced. */
 
96
 
 
97
/* ===================================================================== */
 
98
 
 
99
/*     .. Parameters .. */
 
100
/*     .. */
 
101
/*     .. Local Scalars .. */
 
102
/*     .. */
 
103
/*     .. External Subroutines .. */
 
104
/*     .. */
 
105
/*     .. External Functions .. */
 
106
/*     .. */
 
107
/*     .. Intrinsic Functions .. */
 
108
/*     .. */
 
109
/*     .. Executable Statements .. */
 
110
 
 
111
    /* Parameter adjustments */
 
112
    a_dim1 = *lda;
 
113
    a_offset = 1 + a_dim1;
 
114
    a -= a_offset;
 
115
    --work;
 
116
 
 
117
    /* Function Body */
 
118
    if (*n == 0) {
 
119
        value = 0.;
 
120
    } else if (igraphlsame_(norm, "M")) {
 
121
 
 
122
/*        Find max(abs(A(i,j))). */
 
123
 
 
124
        value = 0.;
 
125
        i__1 = *n;
 
126
        for (j = 1; j <= i__1; ++j) {
 
127
/* Computing MIN */
 
128
            i__3 = *n, i__4 = j + 1;
 
129
            i__2 = min(i__3,i__4);
 
130
            for (i__ = 1; i__ <= i__2; ++i__) {
 
131
/* Computing MAX */
 
132
                d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(d__1));
 
133
                value = max(d__2,d__3);
 
134
/* L10: */
 
135
            }
 
136
/* L20: */
 
137
        }
 
138
    } else if (igraphlsame_(norm, "O") || *(unsigned char *)
 
139
            norm == '1') {
 
140
 
 
141
/*        Find norm1(A). */
 
142
 
 
143
        value = 0.;
 
144
        i__1 = *n;
 
145
        for (j = 1; j <= i__1; ++j) {
 
146
            sum = 0.;
 
147
/* Computing MIN */
 
148
            i__3 = *n, i__4 = j + 1;
 
149
            i__2 = min(i__3,i__4);
 
150
            for (i__ = 1; i__ <= i__2; ++i__) {
 
151
                sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
 
152
/* L30: */
 
153
            }
 
154
            value = max(value,sum);
 
155
/* L40: */
 
156
        }
 
157
    } else if (igraphlsame_(norm, "I")) {
 
158
 
 
159
/*        Find normI(A). */
 
160
 
 
161
        i__1 = *n;
 
162
        for (i__ = 1; i__ <= i__1; ++i__) {
 
163
            work[i__] = 0.;
 
164
/* L50: */
 
165
        }
 
166
        i__1 = *n;
 
167
        for (j = 1; j <= i__1; ++j) {
 
168
/* Computing MIN */
 
169
            i__3 = *n, i__4 = j + 1;
 
170
            i__2 = min(i__3,i__4);
 
171
            for (i__ = 1; i__ <= i__2; ++i__) {
 
172
                work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
 
173
/* L60: */
 
174
            }
 
175
/* L70: */
 
176
        }
 
177
        value = 0.;
 
178
        i__1 = *n;
 
179
        for (i__ = 1; i__ <= i__1; ++i__) {
 
180
/* Computing MAX */
 
181
            d__1 = value, d__2 = work[i__];
 
182
            value = max(d__1,d__2);
 
183
/* L80: */
 
184
        }
 
185
    } else if (igraphlsame_(norm, "F") || igraphlsame_(norm, "E")) {
 
186
 
 
187
/*        Find normF(A). */
 
188
 
 
189
        scale = 0.;
 
190
        sum = 1.;
 
191
        i__1 = *n;
 
192
        for (j = 1; j <= i__1; ++j) {
 
193
/* Computing MIN */
 
194
            i__3 = *n, i__4 = j + 1;
 
195
            i__2 = min(i__3,i__4);
 
196
            igraphdlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
 
197
/* L90: */
 
198
        }
 
199
        value = scale * sqrt(sum);
 
200
    }
 
201
 
 
202
    ret_val = value;
 
203
    return ret_val;
 
204
 
 
205
/*     End of DLANHS */
 
206
 
 
207
} /* igraphdlanhs_ */
 
208