~ubuntu-branches/ubuntu/saucy/igraph/saucy

« back to all changes in this revision

Viewing changes to src/blas/dtrmm.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-05-27 14:01:54 UTC
  • mfrom: (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130527140154-oxwwmr0gj3kdy4ol
Tags: 0.6.5-2
Upload to sid

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 igraphdtrmm_(char *side, char *uplo, char *transa, char *diag, 
18
 
        integer *m, integer *n, doublereal *alpha, doublereal *a, integer *
19
 
        lda, doublereal *b, integer *ldb)
20
 
{
21
 
    /* System generated locals */
22
 
    integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
23
 
 
24
 
    /* Local variables */
25
 
    static integer i__, j, k, info;
26
 
    static doublereal temp;
27
 
    static logical lside;
28
 
    extern logical igraphlsame_(char *, char *);
29
 
    static integer nrowa;
30
 
    static logical upper;
31
 
    extern /* Subroutine */ int igraphxerbla_(char *, integer *);
32
 
    static logical nounit;
33
 
 
34
 
/*     .. Scalar Arguments .. */
35
 
/*     .. Array Arguments .. */
36
 
/*     .. */
37
 
 
38
 
/*  Purpose */
39
 
/*  ======= */
40
 
 
41
 
/*  DTRMM  performs one of the matrix-matrix operations */
42
 
 
43
 
/*     B := alpha*op( A )*B,   or   B := alpha*B*op( A ), */
44
 
 
45
 
/*  where  alpha  is a scalar,  B  is an m by n matrix,  A  is a unit, or */
46
 
/*  non-unit,  upper or lower triangular matrix  and  op( A )  is one  of */
47
 
 
48
 
/*     op( A ) = A   or   op( A ) = A'. */
49
 
 
50
 
/*  Parameters */
51
 
/*  ========== */
52
 
 
53
 
/*  SIDE   - CHARACTER*1. */
54
 
/*           On entry,  SIDE specifies whether  op( A ) multiplies B from */
55
 
/*           the left or right as follows: */
56
 
 
57
 
/*              SIDE = 'L' or 'l'   B := alpha*op( A )*B. */
58
 
 
59
 
/*              SIDE = 'R' or 'r'   B := alpha*B*op( A ). */
60
 
 
61
 
/*           Unchanged on exit. */
62
 
 
63
 
/*  UPLO   - CHARACTER*1. */
64
 
/*           On entry, UPLO specifies whether the matrix A is an upper or */
65
 
/*           lower triangular matrix as follows: */
66
 
 
67
 
/*              UPLO = 'U' or 'u'   A is an upper triangular matrix. */
68
 
 
69
 
/*              UPLO = 'L' or 'l'   A is a lower triangular matrix. */
70
 
 
71
 
/*           Unchanged on exit. */
72
 
 
73
 
/*  TRANSA - CHARACTER*1. */
74
 
/*           On entry, TRANSA specifies the form of op( A ) to be used in */
75
 
/*           the matrix multiplication as follows: */
76
 
 
77
 
/*              TRANSA = 'N' or 'n'   op( A ) = A. */
78
 
 
79
 
/*              TRANSA = 'T' or 't'   op( A ) = A'. */
80
 
 
81
 
/*              TRANSA = 'C' or 'c'   op( A ) = A'. */
82
 
 
83
 
/*           Unchanged on exit. */
84
 
 
85
 
/*  DIAG   - CHARACTER*1. */
86
 
/*           On entry, DIAG specifies whether or not A is unit triangular */
87
 
/*           as follows: */
88
 
 
89
 
/*              DIAG = 'U' or 'u'   A is assumed to be unit triangular. */
90
 
 
91
 
/*              DIAG = 'N' or 'n'   A is not assumed to be unit */
92
 
/*                                  triangular. */
93
 
 
94
 
/*           Unchanged on exit. */
95
 
 
96
 
/*  M      - INTEGER. */
97
 
/*           On entry, M specifies the number of rows of B. M must be at */
98
 
/*           least zero. */
99
 
/*           Unchanged on exit. */
100
 
 
101
 
/*  N      - INTEGER. */
102
 
/*           On entry, N specifies the number of columns of B.  N must be */
103
 
/*           at least zero. */
104
 
/*           Unchanged on exit. */
105
 
 
106
 
/*  ALPHA  - DOUBLE PRECISION. */
107
 
/*           On entry,  ALPHA specifies the scalar  alpha. When  alpha is */
108
 
/*           zero then  A is not referenced and  B need not be set before */
109
 
/*           entry. */
110
 
/*           Unchanged on exit. */
111
 
 
112
 
/*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, k ), where k is m */
113
 
/*           when  SIDE = 'L' or 'l'  and is  n  when  SIDE = 'R' or 'r'. */
114
 
/*           Before entry  with  UPLO = 'U' or 'u',  the  leading  k by k */
115
 
/*           upper triangular part of the array  A must contain the upper */
116
 
/*           triangular matrix  and the strictly lower triangular part of */
117
 
/*           A is not referenced. */
118
 
/*           Before entry  with  UPLO = 'L' or 'l',  the  leading  k by k */
119
 
/*           lower triangular part of the array  A must contain the lower */
120
 
/*           triangular matrix  and the strictly upper triangular part of */
121
 
/*           A is not referenced. */
122
 
/*           Note that when  DIAG = 'U' or 'u',  the diagonal elements of */
123
 
/*           A  are not referenced either,  but are assumed to be  unity. */
124
 
/*           Unchanged on exit. */
125
 
 
126
 
/*  LDA    - INTEGER. */
127
 
/*           On entry, LDA specifies the first dimension of A as declared */
128
 
/*           in the calling (sub) program.  When  SIDE = 'L' or 'l'  then */
129
 
/*           LDA  must be at least  max( 1, m ),  when  SIDE = 'R' or 'r' */
130
 
/*           then LDA must be at least max( 1, n ). */
131
 
/*           Unchanged on exit. */
132
 
 
133
 
/*  B      - DOUBLE PRECISION array of DIMENSION ( LDB, n ). */
134
 
/*           Before entry,  the leading  m by n part of the array  B must */
135
 
/*           contain the matrix  B,  and  on exit  is overwritten  by the */
136
 
/*           transformed matrix. */
137
 
 
138
 
/*  LDB    - INTEGER. */
139
 
/*           On entry, LDB specifies the first dimension of B as declared */
140
 
/*           in  the  calling  (sub)  program.   LDB  must  be  at  least */
141
 
/*           max( 1, m ). */
142
 
/*           Unchanged on exit. */
143
 
 
144
 
 
145
 
/*  Level 3 Blas routine. */
146
 
 
147
 
/*  -- Written on 8-February-1989. */
148
 
/*     Jack Dongarra, Argonne National Laboratory. */
149
 
/*     Iain Duff, AERE Harwell. */
150
 
/*     Jeremy Du Croz, Numerical Algorithms Group Ltd. */
151
 
/*     Sven Hammarling, Numerical Algorithms Group Ltd. */
152
 
 
153
 
 
154
 
/*     .. External Functions .. */
155
 
/*     .. External Subroutines .. */
156
 
/*     .. Intrinsic Functions .. */
157
 
/*     .. Local Scalars .. */
158
 
/*     .. Parameters .. */
159
 
/*     .. */
160
 
/*     .. Executable Statements .. */
161
 
 
162
 
/*     Test the input parameters. */
163
 
 
164
 
    /* Parameter adjustments */
165
 
    a_dim1 = *lda;
166
 
    a_offset = 1 + a_dim1;
167
 
    a -= a_offset;
168
 
    b_dim1 = *ldb;
169
 
    b_offset = 1 + b_dim1;
170
 
    b -= b_offset;
171
 
 
172
 
    /* Function Body */
173
 
    lside = igraphlsame_(side, "L");
174
 
    if (lside) {
175
 
        nrowa = *m;
176
 
    } else {
177
 
        nrowa = *n;
178
 
    }
179
 
    nounit = igraphlsame_(diag, "N");
180
 
    upper = igraphlsame_(uplo, "U");
181
 
 
182
 
    info = 0;
183
 
    if (! lside && ! igraphlsame_(side, "R")) {
184
 
        info = 1;
185
 
    } else if (! upper && ! igraphlsame_(uplo, "L")) {
186
 
        info = 2;
187
 
    } else if (! igraphlsame_(transa, "N") && ! igraphlsame_(transa,
188
 
             "T") && ! igraphlsame_(transa, "C")) {
189
 
        info = 3;
190
 
    } else if (! igraphlsame_(diag, "U") && ! igraphlsame_(diag, 
191
 
            "N")) {
192
 
        info = 4;
193
 
    } else if (*m < 0) {
194
 
        info = 5;
195
 
    } else if (*n < 0) {
196
 
        info = 6;
197
 
    } else if (*lda < max(1,nrowa)) {
198
 
        info = 9;
199
 
    } else if (*ldb < max(1,*m)) {
200
 
        info = 11;
201
 
    }
202
 
    if (info != 0) {
203
 
        igraphxerbla_("DTRMM ", &info);
204
 
        return 0;
205
 
    }
206
 
 
207
 
/*     Quick return if possible. */
208
 
 
209
 
    if (*n == 0) {
210
 
        return 0;
211
 
    }
212
 
 
213
 
/*     And when  alpha.eq.zero. */
214
 
 
215
 
    if (*alpha == 0.) {
216
 
        i__1 = *n;
217
 
        for (j = 1; j <= i__1; ++j) {
218
 
            i__2 = *m;
219
 
            for (i__ = 1; i__ <= i__2; ++i__) {
220
 
                b[i__ + j * b_dim1] = 0.;
221
 
/* L10: */
222
 
            }
223
 
/* L20: */
224
 
        }
225
 
        return 0;
226
 
    }
227
 
 
228
 
/*     Start the operations. */
229
 
 
230
 
    if (lside) {
231
 
        if (igraphlsame_(transa, "N")) {
232
 
 
233
 
/*           Form  B := alpha*A*B. */
234
 
 
235
 
            if (upper) {
236
 
                i__1 = *n;
237
 
                for (j = 1; j <= i__1; ++j) {
238
 
                    i__2 = *m;
239
 
                    for (k = 1; k <= i__2; ++k) {
240
 
                        if (b[k + j * b_dim1] != 0.) {
241
 
                            temp = *alpha * b[k + j * b_dim1];
242
 
                            i__3 = k - 1;
243
 
                            for (i__ = 1; i__ <= i__3; ++i__) {
244
 
                                b[i__ + j * b_dim1] += temp * a[i__ + k * 
245
 
                                        a_dim1];
246
 
/* L30: */
247
 
                            }
248
 
                            if (nounit) {
249
 
                                temp *= a[k + k * a_dim1];
250
 
                            }
251
 
                            b[k + j * b_dim1] = temp;
252
 
                        }
253
 
/* L40: */
254
 
                    }
255
 
/* L50: */
256
 
                }
257
 
            } else {
258
 
                i__1 = *n;
259
 
                for (j = 1; j <= i__1; ++j) {
260
 
                    for (k = *m; k >= 1; --k) {
261
 
                        if (b[k + j * b_dim1] != 0.) {
262
 
                            temp = *alpha * b[k + j * b_dim1];
263
 
                            b[k + j * b_dim1] = temp;
264
 
                            if (nounit) {
265
 
                                b[k + j * b_dim1] *= a[k + k * a_dim1];
266
 
                            }
267
 
                            i__2 = *m;
268
 
                            for (i__ = k + 1; i__ <= i__2; ++i__) {
269
 
                                b[i__ + j * b_dim1] += temp * a[i__ + k * 
270
 
                                        a_dim1];
271
 
/* L60: */
272
 
                            }
273
 
                        }
274
 
/* L70: */
275
 
                    }
276
 
/* L80: */
277
 
                }
278
 
            }
279
 
        } else {
280
 
 
281
 
/*           Form  B := alpha*A'*B. */
282
 
 
283
 
            if (upper) {
284
 
                i__1 = *n;
285
 
                for (j = 1; j <= i__1; ++j) {
286
 
                    for (i__ = *m; i__ >= 1; --i__) {
287
 
                        temp = b[i__ + j * b_dim1];
288
 
                        if (nounit) {
289
 
                            temp *= a[i__ + i__ * a_dim1];
290
 
                        }
291
 
                        i__2 = i__ - 1;
292
 
                        for (k = 1; k <= i__2; ++k) {
293
 
                            temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
294
 
/* L90: */
295
 
                        }
296
 
                        b[i__ + j * b_dim1] = *alpha * temp;
297
 
/* L100: */
298
 
                    }
299
 
/* L110: */
300
 
                }
301
 
            } else {
302
 
                i__1 = *n;
303
 
                for (j = 1; j <= i__1; ++j) {
304
 
                    i__2 = *m;
305
 
                    for (i__ = 1; i__ <= i__2; ++i__) {
306
 
                        temp = b[i__ + j * b_dim1];
307
 
                        if (nounit) {
308
 
                            temp *= a[i__ + i__ * a_dim1];
309
 
                        }
310
 
                        i__3 = *m;
311
 
                        for (k = i__ + 1; k <= i__3; ++k) {
312
 
                            temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
313
 
/* L120: */
314
 
                        }
315
 
                        b[i__ + j * b_dim1] = *alpha * temp;
316
 
/* L130: */
317
 
                    }
318
 
/* L140: */
319
 
                }
320
 
            }
321
 
        }
322
 
    } else {
323
 
        if (igraphlsame_(transa, "N")) {
324
 
 
325
 
/*           Form  B := alpha*B*A. */
326
 
 
327
 
            if (upper) {
328
 
                for (j = *n; j >= 1; --j) {
329
 
                    temp = *alpha;
330
 
                    if (nounit) {
331
 
                        temp *= a[j + j * a_dim1];
332
 
                    }
333
 
                    i__1 = *m;
334
 
                    for (i__ = 1; i__ <= i__1; ++i__) {
335
 
                        b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
336
 
/* L150: */
337
 
                    }
338
 
                    i__1 = j - 1;
339
 
                    for (k = 1; k <= i__1; ++k) {
340
 
                        if (a[k + j * a_dim1] != 0.) {
341
 
                            temp = *alpha * a[k + j * a_dim1];
342
 
                            i__2 = *m;
343
 
                            for (i__ = 1; i__ <= i__2; ++i__) {
344
 
                                b[i__ + j * b_dim1] += temp * b[i__ + k * 
345
 
                                        b_dim1];
346
 
/* L160: */
347
 
                            }
348
 
                        }
349
 
/* L170: */
350
 
                    }
351
 
/* L180: */
352
 
                }
353
 
            } else {
354
 
                i__1 = *n;
355
 
                for (j = 1; j <= i__1; ++j) {
356
 
                    temp = *alpha;
357
 
                    if (nounit) {
358
 
                        temp *= a[j + j * a_dim1];
359
 
                    }
360
 
                    i__2 = *m;
361
 
                    for (i__ = 1; i__ <= i__2; ++i__) {
362
 
                        b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
363
 
/* L190: */
364
 
                    }
365
 
                    i__2 = *n;
366
 
                    for (k = j + 1; k <= i__2; ++k) {
367
 
                        if (a[k + j * a_dim1] != 0.) {
368
 
                            temp = *alpha * a[k + j * a_dim1];
369
 
                            i__3 = *m;
370
 
                            for (i__ = 1; i__ <= i__3; ++i__) {
371
 
                                b[i__ + j * b_dim1] += temp * b[i__ + k * 
372
 
                                        b_dim1];
373
 
/* L200: */
374
 
                            }
375
 
                        }
376
 
/* L210: */
377
 
                    }
378
 
/* L220: */
379
 
                }
380
 
            }
381
 
        } else {
382
 
 
383
 
/*           Form  B := alpha*B*A'. */
384
 
 
385
 
            if (upper) {
386
 
                i__1 = *n;
387
 
                for (k = 1; k <= i__1; ++k) {
388
 
                    i__2 = k - 1;
389
 
                    for (j = 1; j <= i__2; ++j) {
390
 
                        if (a[j + k * a_dim1] != 0.) {
391
 
                            temp = *alpha * a[j + k * a_dim1];
392
 
                            i__3 = *m;
393
 
                            for (i__ = 1; i__ <= i__3; ++i__) {
394
 
                                b[i__ + j * b_dim1] += temp * b[i__ + k * 
395
 
                                        b_dim1];
396
 
/* L230: */
397
 
                            }
398
 
                        }
399
 
/* L240: */
400
 
                    }
401
 
                    temp = *alpha;
402
 
                    if (nounit) {
403
 
                        temp *= a[k + k * a_dim1];
404
 
                    }
405
 
                    if (temp != 1.) {
406
 
                        i__2 = *m;
407
 
                        for (i__ = 1; i__ <= i__2; ++i__) {
408
 
                            b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
409
 
/* L250: */
410
 
                        }
411
 
                    }
412
 
/* L260: */
413
 
                }
414
 
            } else {
415
 
                for (k = *n; k >= 1; --k) {
416
 
                    i__1 = *n;
417
 
                    for (j = k + 1; j <= i__1; ++j) {
418
 
                        if (a[j + k * a_dim1] != 0.) {
419
 
                            temp = *alpha * a[j + k * a_dim1];
420
 
                            i__2 = *m;
421
 
                            for (i__ = 1; i__ <= i__2; ++i__) {
422
 
                                b[i__ + j * b_dim1] += temp * b[i__ + k * 
423
 
                                        b_dim1];
424
 
/* L270: */
425
 
                            }
426
 
                        }
427
 
/* L280: */
428
 
                    }
429
 
                    temp = *alpha;
430
 
                    if (nounit) {
431
 
                        temp *= a[k + k * a_dim1];
432
 
                    }
433
 
                    if (temp != 1.) {
434
 
                        i__1 = *m;
435
 
                        for (i__ = 1; i__ <= i__1; ++i__) {
436
 
                            b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
437
 
/* L290: */
438
 
                        }
439
 
                    }
440
 
/* L300: */
441
 
                }
442
 
            }
443
 
        }
444
 
    }
445
 
 
446
 
    return 0;
447
 
 
448
 
/*     End of DTRMM . */
449
 
 
450
 
} /* igraphdtrmm_ */
451