Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / slauu2.c
1 #include "clapack.h"
2
3 /* Table of constant values */
4
5 static real c_b7 = 1.f;
6 static integer c__1 = 1;
7
8 /* Subroutine */ int slauu2_(char *uplo, integer *n, real *a, integer *lda, 
9         integer *info)
10 {
11     /* System generated locals */
12     integer a_dim1, a_offset, i__1, i__2, i__3;
13
14     /* Local variables */
15     integer i__;
16     real aii;
17     extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
18     extern logical lsame_(char *, char *);
19     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
20             sgemv_(char *, integer *, integer *, real *, real *, integer *, 
21             real *, integer *, real *, real *, integer *);
22     logical upper;
23     extern /* Subroutine */ int xerbla_(char *, integer *);
24
25
26 /*  -- LAPACK auxiliary routine (version 3.1) -- */
27 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
28 /*     November 2006 */
29
30 /*     .. Scalar Arguments .. */
31 /*     .. */
32 /*     .. Array Arguments .. */
33 /*     .. */
34
35 /*  Purpose */
36 /*  ======= */
37
38 /*  SLAUU2 computes the product U * U' or L' * L, where the triangular */
39 /*  factor U or L is stored in the upper or lower triangular part of */
40 /*  the array A. */
41
42 /*  If UPLO = 'U' or 'u' then the upper triangle of the result is stored, */
43 /*  overwriting the factor U in A. */
44 /*  If UPLO = 'L' or 'l' then the lower triangle of the result is stored, */
45 /*  overwriting the factor L in A. */
46
47 /*  This is the unblocked form of the algorithm, calling Level 2 BLAS. */
48
49 /*  Arguments */
50 /*  ========= */
51
52 /*  UPLO    (input) CHARACTER*1 */
53 /*          Specifies whether the triangular factor stored in the array A */
54 /*          is upper or lower triangular: */
55 /*          = 'U':  Upper triangular */
56 /*          = 'L':  Lower triangular */
57
58 /*  N       (input) INTEGER */
59 /*          The order of the triangular factor U or L.  N >= 0. */
60
61 /*  A       (input/output) REAL array, dimension (LDA,N) */
62 /*          On entry, the triangular factor U or L. */
63 /*          On exit, if UPLO = 'U', the upper triangle of A is */
64 /*          overwritten with the upper triangle of the product U * U'; */
65 /*          if UPLO = 'L', the lower triangle of A is overwritten with */
66 /*          the lower triangle of the product L' * L. */
67
68 /*  LDA     (input) INTEGER */
69 /*          The leading dimension of the array A.  LDA >= max(1,N). */
70
71 /*  INFO    (output) INTEGER */
72 /*          = 0: successful exit */
73 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
74
75 /*  ===================================================================== */
76
77 /*     .. Parameters .. */
78 /*     .. */
79 /*     .. Local Scalars .. */
80 /*     .. */
81 /*     .. External Functions .. */
82 /*     .. */
83 /*     .. External Subroutines .. */
84 /*     .. */
85 /*     .. Intrinsic Functions .. */
86 /*     .. */
87 /*     .. Executable Statements .. */
88
89 /*     Test the input parameters. */
90
91     /* Parameter adjustments */
92     a_dim1 = *lda;
93     a_offset = 1 + a_dim1;
94     a -= a_offset;
95
96     /* Function Body */
97     *info = 0;
98     upper = lsame_(uplo, "U");
99     if (! upper && ! lsame_(uplo, "L")) {
100         *info = -1;
101     } else if (*n < 0) {
102         *info = -2;
103     } else if (*lda < max(1,*n)) {
104         *info = -4;
105     }
106     if (*info != 0) {
107         i__1 = -(*info);
108         xerbla_("SLAUU2", &i__1);
109         return 0;
110     }
111
112 /*     Quick return if possible */
113
114     if (*n == 0) {
115         return 0;
116     }
117
118     if (upper) {
119
120 /*        Compute the product U * U'. */
121
122         i__1 = *n;
123         for (i__ = 1; i__ <= i__1; ++i__) {
124             aii = a[i__ + i__ * a_dim1];
125             if (i__ < *n) {
126                 i__2 = *n - i__ + 1;
127                 a[i__ + i__ * a_dim1] = sdot_(&i__2, &a[i__ + i__ * a_dim1], 
128                         lda, &a[i__ + i__ * a_dim1], lda);
129                 i__2 = i__ - 1;
130                 i__3 = *n - i__;
131                 sgemv_("No transpose", &i__2, &i__3, &c_b7, &a[(i__ + 1) * 
132                         a_dim1 + 1], lda, &a[i__ + (i__ + 1) * a_dim1], lda, &
133                         aii, &a[i__ * a_dim1 + 1], &c__1);
134             } else {
135                 sscal_(&i__, &aii, &a[i__ * a_dim1 + 1], &c__1);
136             }
137 /* L10: */
138         }
139
140     } else {
141
142 /*        Compute the product L' * L. */
143
144         i__1 = *n;
145         for (i__ = 1; i__ <= i__1; ++i__) {
146             aii = a[i__ + i__ * a_dim1];
147             if (i__ < *n) {
148                 i__2 = *n - i__ + 1;
149                 a[i__ + i__ * a_dim1] = sdot_(&i__2, &a[i__ + i__ * a_dim1], &
150                         c__1, &a[i__ + i__ * a_dim1], &c__1);
151                 i__2 = *n - i__;
152                 i__3 = i__ - 1;
153                 sgemv_("Transpose", &i__2, &i__3, &c_b7, &a[i__ + 1 + a_dim1], 
154                          lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &aii, &a[i__ 
155                         + a_dim1], lda);
156             } else {
157                 sscal_(&i__, &aii, &a[i__ + a_dim1], lda);
158             }
159 /* L20: */
160         }
161     }
162
163     return 0;
164
165 /*     End of SLAUU2 */
166
167 } /* slauu2_ */