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