~ubuntu-branches/ubuntu/precise/igraph/precise

« back to all changes in this revision

Viewing changes to src/lapack/dlascl.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
/* Subroutine */ int igraphdlascl_(char *type__, integer *kl, integer *ku, 
 
18
        doublereal *cfrom, doublereal *cto, integer *m, integer *n, 
 
19
        doublereal *a, integer *lda, integer *info)
 
20
{
 
21
    /* System generated locals */
 
22
    integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
 
23
 
 
24
    /* Local variables */
 
25
    static integer i__, j, k1, k2, k3, k4;
 
26
    static doublereal mul, cto1;
 
27
    static logical done;
 
28
    static doublereal ctoc;
 
29
    extern logical igraphlsame_(char *, char *);
 
30
    static integer itype;
 
31
    static doublereal cfrom1;
 
32
    extern doublereal igraphdlamch_(char *);
 
33
    static doublereal cfromc;
 
34
    extern /* Subroutine */ int igraphxerbla_(char *, integer *);
 
35
    static doublereal bignum, smlnum;
 
36
 
 
37
 
 
38
/*  -- LAPACK auxiliary routine (version 3.0) -- */
 
39
/*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
 
40
/*     Courant Institute, Argonne National Lab, and Rice University */
 
41
/*     February 29, 1992 */
 
42
 
 
43
/*     .. Scalar Arguments .. */
 
44
/*     .. */
 
45
/*     .. Array Arguments .. */
 
46
/*     .. */
 
47
 
 
48
/*  Purpose */
 
49
/*  ======= */
 
50
 
 
51
/*  DLASCL multiplies the M by N real matrix A by the real scalar */
 
52
/*  CTO/CFROM.  This is done without over/underflow as long as the final */
 
53
/*  result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that */
 
54
/*  A may be full, upper triangular, lower triangular, upper Hessenberg, */
 
55
/*  or banded. */
 
56
 
 
57
/*  Arguments */
 
58
/*  ========= */
 
59
 
 
60
/*  TYPE    (input) CHARACTER*1 */
 
61
/*          TYPE indices the storage type of the input matrix. */
 
62
/*          = 'G':  A is a full matrix. */
 
63
/*          = 'L':  A is a lower triangular matrix. */
 
64
/*          = 'U':  A is an upper triangular matrix. */
 
65
/*          = 'H':  A is an upper Hessenberg matrix. */
 
66
/*          = 'B':  A is a symmetric band matrix with lower bandwidth KL */
 
67
/*                  and upper bandwidth KU and with the only the lower */
 
68
/*                  half stored. */
 
69
/*          = 'Q':  A is a symmetric band matrix with lower bandwidth KL */
 
70
/*                  and upper bandwidth KU and with the only the upper */
 
71
/*                  half stored. */
 
72
/*          = 'Z':  A is a band matrix with lower bandwidth KL and upper */
 
73
/*                  bandwidth KU. */
 
74
 
 
75
/*  KL      (input) INTEGER */
 
76
/*          The lower bandwidth of A.  Referenced only if TYPE = 'B', */
 
77
/*          'Q' or 'Z'. */
 
78
 
 
79
/*  KU      (input) INTEGER */
 
80
/*          The upper bandwidth of A.  Referenced only if TYPE = 'B', */
 
81
/*          'Q' or 'Z'. */
 
82
 
 
83
/*  CFROM   (input) DOUBLE PRECISION */
 
84
/*  CTO     (input) DOUBLE PRECISION */
 
85
/*          The matrix A is multiplied by CTO/CFROM. A(I,J) is computed */
 
86
/*          without over/underflow if the final result CTO*A(I,J)/CFROM */
 
87
/*          can be represented without over/underflow.  CFROM must be */
 
88
/*          nonzero. */
 
89
 
 
90
/*  M       (input) INTEGER */
 
91
/*          The number of rows of the matrix A.  M >= 0. */
 
92
 
 
93
/*  N       (input) INTEGER */
 
94
/*          The number of columns of the matrix A.  N >= 0. */
 
95
 
 
96
/*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,M) */
 
97
/*          The matrix to be multiplied by CTO/CFROM.  See TYPE for the */
 
98
/*          storage type. */
 
99
 
 
100
/*  LDA     (input) INTEGER */
 
101
/*          The leading dimension of the array A.  LDA >= max(1,M). */
 
102
 
 
103
/*  INFO    (output) INTEGER */
 
104
/*          0  - successful exit */
 
105
/*          <0 - if INFO = -i, the i-th argument had an illegal value. */
 
106
 
 
107
/*  ===================================================================== */
 
108
 
 
109
/*     .. Parameters .. */
 
110
/*     .. */
 
111
/*     .. Local Scalars .. */
 
112
/*     .. */
 
113
/*     .. External Functions .. */
 
114
/*     .. */
 
115
/*     .. Intrinsic Functions .. */
 
116
/*     .. */
 
117
/*     .. External Subroutines .. */
 
118
/*     .. */
 
119
/*     .. Executable Statements .. */
 
120
 
 
121
/*     Test the input arguments */
 
122
 
 
123
    /* Parameter adjustments */
 
124
    a_dim1 = *lda;
 
125
    a_offset = 1 + a_dim1;
 
126
    a -= a_offset;
 
127
 
 
128
    /* Function Body */
 
129
    *info = 0;
 
130
 
 
131
    if (igraphlsame_(type__, "G")) {
 
132
        itype = 0;
 
133
    } else if (igraphlsame_(type__, "L")) {
 
134
        itype = 1;
 
135
    } else if (igraphlsame_(type__, "U")) {
 
136
        itype = 2;
 
137
    } else if (igraphlsame_(type__, "H")) {
 
138
        itype = 3;
 
139
    } else if (igraphlsame_(type__, "B")) {
 
140
        itype = 4;
 
141
    } else if (igraphlsame_(type__, "Q")) {
 
142
        itype = 5;
 
143
    } else if (igraphlsame_(type__, "Z")) {
 
144
        itype = 6;
 
145
    } else {
 
146
        itype = -1;
 
147
    }
 
148
 
 
149
    if (itype == -1) {
 
150
        *info = -1;
 
151
    } else if (*cfrom == 0.) {
 
152
        *info = -4;
 
153
    } else if (*m < 0) {
 
154
        *info = -6;
 
155
    } else if (*n < 0 || (itype == 4 && *n != *m) || (itype == 5 && *n != *m)) {
 
156
        *info = -7;
 
157
    } else if (itype <= 3 && *lda < max(1,*m)) {
 
158
        *info = -9;
 
159
    } else if (itype >= 4) {
 
160
/* Computing MAX */
 
161
        i__1 = *m - 1;
 
162
        if (*kl < 0 || *kl > max(i__1,0)) {
 
163
            *info = -2;
 
164
        } else /* if(complicated condition) */ {
 
165
/* Computing MAX */
 
166
            i__1 = *n - 1;
 
167
            if (*ku < 0 || *ku > max(i__1,0) || ((itype == 4 || itype == 5) && 
 
168
                                                 *kl != *ku)) {
 
169
                *info = -3;
 
170
            } else if ((itype == 4 && *lda < *kl + 1) || (itype == 5 && *lda < *
 
171
                       ku + 1) || (itype == 6 && *lda < (*kl << 1) + *ku + 1)) {
 
172
                *info = -9;
 
173
            }
 
174
        }
 
175
    }
 
176
 
 
177
    if (*info != 0) {
 
178
        i__1 = -(*info);
 
179
        igraphxerbla_("DLASCL", &i__1);
 
180
        return 0;
 
181
    }
 
182
 
 
183
/*     Quick return if possible */
 
184
 
 
185
    if (*n == 0 || *m == 0) {
 
186
        return 0;
 
187
    }
 
188
 
 
189
/*     Get machine parameters */
 
190
 
 
191
    smlnum = igraphdlamch_("S");
 
192
    bignum = 1. / smlnum;
 
193
 
 
194
    cfromc = *cfrom;
 
195
    ctoc = *cto;
 
196
 
 
197
L10:
 
198
    cfrom1 = cfromc * smlnum;
 
199
    cto1 = ctoc / bignum;
 
200
    if (abs(cfrom1) > abs(ctoc) && ctoc != 0.) {
 
201
        mul = smlnum;
 
202
        done = FALSE_;
 
203
        cfromc = cfrom1;
 
204
    } else if (abs(cto1) > abs(cfromc)) {
 
205
        mul = bignum;
 
206
        done = FALSE_;
 
207
        ctoc = cto1;
 
208
    } else {
 
209
        mul = ctoc / cfromc;
 
210
        done = TRUE_;
 
211
    }
 
212
 
 
213
    if (itype == 0) {
 
214
 
 
215
/*        Full matrix */
 
216
 
 
217
        i__1 = *n;
 
218
        for (j = 1; j <= i__1; ++j) {
 
219
            i__2 = *m;
 
220
            for (i__ = 1; i__ <= i__2; ++i__) {
 
221
                a[i__ + j * a_dim1] *= mul;
 
222
/* L20: */
 
223
            }
 
224
/* L30: */
 
225
        }
 
226
 
 
227
    } else if (itype == 1) {
 
228
 
 
229
/*        Lower triangular matrix */
 
230
 
 
231
        i__1 = *n;
 
232
        for (j = 1; j <= i__1; ++j) {
 
233
            i__2 = *m;
 
234
            for (i__ = j; i__ <= i__2; ++i__) {
 
235
                a[i__ + j * a_dim1] *= mul;
 
236
/* L40: */
 
237
            }
 
238
/* L50: */
 
239
        }
 
240
 
 
241
    } else if (itype == 2) {
 
242
 
 
243
/*        Upper triangular matrix */
 
244
 
 
245
        i__1 = *n;
 
246
        for (j = 1; j <= i__1; ++j) {
 
247
            i__2 = min(j,*m);
 
248
            for (i__ = 1; i__ <= i__2; ++i__) {
 
249
                a[i__ + j * a_dim1] *= mul;
 
250
/* L60: */
 
251
            }
 
252
/* L70: */
 
253
        }
 
254
 
 
255
    } else if (itype == 3) {
 
256
 
 
257
/*        Upper Hessenberg matrix */
 
258
 
 
259
        i__1 = *n;
 
260
        for (j = 1; j <= i__1; ++j) {
 
261
/* Computing MIN */
 
262
            i__3 = j + 1;
 
263
            i__2 = min(i__3,*m);
 
264
            for (i__ = 1; i__ <= i__2; ++i__) {
 
265
                a[i__ + j * a_dim1] *= mul;
 
266
/* L80: */
 
267
            }
 
268
/* L90: */
 
269
        }
 
270
 
 
271
    } else if (itype == 4) {
 
272
 
 
273
/*        Lower half of a symmetric band matrix */
 
274
 
 
275
        k3 = *kl + 1;
 
276
        k4 = *n + 1;
 
277
        i__1 = *n;
 
278
        for (j = 1; j <= i__1; ++j) {
 
279
/* Computing MIN */
 
280
            i__3 = k3, i__4 = k4 - j;
 
281
            i__2 = min(i__3,i__4);
 
282
            for (i__ = 1; i__ <= i__2; ++i__) {
 
283
                a[i__ + j * a_dim1] *= mul;
 
284
/* L100: */
 
285
            }
 
286
/* L110: */
 
287
        }
 
288
 
 
289
    } else if (itype == 5) {
 
290
 
 
291
/*        Upper half of a symmetric band matrix */
 
292
 
 
293
        k1 = *ku + 2;
 
294
        k3 = *ku + 1;
 
295
        i__1 = *n;
 
296
        for (j = 1; j <= i__1; ++j) {
 
297
/* Computing MAX */
 
298
            i__2 = k1 - j;
 
299
            i__3 = k3;
 
300
            for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
 
301
                a[i__ + j * a_dim1] *= mul;
 
302
/* L120: */
 
303
            }
 
304
/* L130: */
 
305
        }
 
306
 
 
307
    } else if (itype == 6) {
 
308
 
 
309
/*        Band matrix */
 
310
 
 
311
        k1 = *kl + *ku + 2;
 
312
        k2 = *kl + 1;
 
313
        k3 = (*kl << 1) + *ku + 1;
 
314
        k4 = *kl + *ku + 1 + *m;
 
315
        i__1 = *n;
 
316
        for (j = 1; j <= i__1; ++j) {
 
317
/* Computing MAX */
 
318
            i__3 = k1 - j;
 
319
/* Computing MIN */
 
320
            i__4 = k3, i__5 = k4 - j;
 
321
            i__2 = min(i__4,i__5);
 
322
            for (i__ = max(i__3,k2); i__ <= i__2; ++i__) {
 
323
                a[i__ + j * a_dim1] *= mul;
 
324
/* L140: */
 
325
            }
 
326
/* L150: */
 
327
        }
 
328
 
 
329
    }
 
330
 
 
331
    if (! done) {
 
332
        goto L10;
 
333
    }
 
334
 
 
335
    return 0;
 
336
 
 
337
/*     End of DLASCL */
 
338
 
 
339
} /* igraphdlascl_ */
 
340