f826a2df048a3fc839c588185f1e02b53570e919
[profile/ivi/opencv.git] / 3rdparty / lapack / dorm2l.c
1 /* dorm2l.f -- translated by f2c (version 20061008).
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 "clapack.h"
14
15
16 /* Table of constant values */
17
18 static integer c__1 = 1;
19
20 /* Subroutine */ int dorm2l_(char *side, char *trans, integer *m, integer *n, 
21         integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *
22         c__, integer *ldc, doublereal *work, integer *info)
23 {
24     /* System generated locals */
25     integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2;
26
27     /* Local variables */
28     integer i__, i1, i2, i3, mi, ni, nq;
29     doublereal aii;
30     logical left;
31     extern /* Subroutine */ int dlarf_(char *, integer *, integer *, 
32             doublereal *, integer *, doublereal *, doublereal *, integer *, 
33             doublereal *);
34     extern logical lsame_(char *, char *);
35     extern /* Subroutine */ int xerbla_(char *, integer *);
36     logical notran;
37
38
39 /*  -- LAPACK routine (version 3.2) -- */
40 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
41 /*     November 2006 */
42
43 /*     .. Scalar Arguments .. */
44 /*     .. */
45 /*     .. Array Arguments .. */
46 /*     .. */
47
48 /*  Purpose */
49 /*  ======= */
50
51 /*  DORM2L overwrites the general real m by n matrix C with */
52
53 /*        Q * C  if SIDE = 'L' and TRANS = 'N', or */
54
55 /*        Q'* C  if SIDE = 'L' and TRANS = 'T', or */
56
57 /*        C * Q  if SIDE = 'R' and TRANS = 'N', or */
58
59 /*        C * Q' if SIDE = 'R' and TRANS = 'T', */
60
61 /*  where Q is a real orthogonal matrix defined as the product of k */
62 /*  elementary reflectors */
63
64 /*        Q = H(k) . . . H(2) H(1) */
65
66 /*  as returned by DGEQLF. Q is of order m if SIDE = 'L' and of order n */
67 /*  if SIDE = 'R'. */
68
69 /*  Arguments */
70 /*  ========= */
71
72 /*  SIDE    (input) CHARACTER*1 */
73 /*          = 'L': apply Q or Q' from the Left */
74 /*          = 'R': apply Q or Q' from the Right */
75
76 /*  TRANS   (input) CHARACTER*1 */
77 /*          = 'N': apply Q  (No transpose) */
78 /*          = 'T': apply Q' (Transpose) */
79
80 /*  M       (input) INTEGER */
81 /*          The number of rows of the matrix C. M >= 0. */
82
83 /*  N       (input) INTEGER */
84 /*          The number of columns of the matrix C. N >= 0. */
85
86 /*  K       (input) INTEGER */
87 /*          The number of elementary reflectors whose product defines */
88 /*          the matrix Q. */
89 /*          If SIDE = 'L', M >= K >= 0; */
90 /*          if SIDE = 'R', N >= K >= 0. */
91
92 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,K) */
93 /*          The i-th column must contain the vector which defines the */
94 /*          elementary reflector H(i), for i = 1,2,...,k, as returned by */
95 /*          DGEQLF in the last k columns of its array argument A. */
96 /*          A is modified by the routine but restored on exit. */
97
98 /*  LDA     (input) INTEGER */
99 /*          The leading dimension of the array A. */
100 /*          If SIDE = 'L', LDA >= max(1,M); */
101 /*          if SIDE = 'R', LDA >= max(1,N). */
102
103 /*  TAU     (input) DOUBLE PRECISION array, dimension (K) */
104 /*          TAU(i) must contain the scalar factor of the elementary */
105 /*          reflector H(i), as returned by DGEQLF. */
106
107 /*  C       (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
108 /*          On entry, the m by n matrix C. */
109 /*          On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */
110
111 /*  LDC     (input) INTEGER */
112 /*          The leading dimension of the array C. LDC >= max(1,M). */
113
114 /*  WORK    (workspace) DOUBLE PRECISION array, dimension */
115 /*                                   (N) if SIDE = 'L', */
116 /*                                   (M) if SIDE = 'R' */
117
118 /*  INFO    (output) INTEGER */
119 /*          = 0: successful exit */
120 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
121
122 /*  ===================================================================== */
123
124 /*     .. Parameters .. */
125 /*     .. */
126 /*     .. Local Scalars .. */
127 /*     .. */
128 /*     .. External Functions .. */
129 /*     .. */
130 /*     .. External Subroutines .. */
131 /*     .. */
132 /*     .. Intrinsic Functions .. */
133 /*     .. */
134 /*     .. Executable Statements .. */
135
136 /*     Test the input arguments */
137
138     /* Parameter adjustments */
139     a_dim1 = *lda;
140     a_offset = 1 + a_dim1;
141     a -= a_offset;
142     --tau;
143     c_dim1 = *ldc;
144     c_offset = 1 + c_dim1;
145     c__ -= c_offset;
146     --work;
147
148     /* Function Body */
149     *info = 0;
150     left = lsame_(side, "L");
151     notran = lsame_(trans, "N");
152
153 /*     NQ is the order of Q */
154
155     if (left) {
156         nq = *m;
157     } else {
158         nq = *n;
159     }
160     if (! left && ! lsame_(side, "R")) {
161         *info = -1;
162     } else if (! notran && ! lsame_(trans, "T")) {
163         *info = -2;
164     } else if (*m < 0) {
165         *info = -3;
166     } else if (*n < 0) {
167         *info = -4;
168     } else if (*k < 0 || *k > nq) {
169         *info = -5;
170     } else if (*lda < max(1,nq)) {
171         *info = -7;
172     } else if (*ldc < max(1,*m)) {
173         *info = -10;
174     }
175     if (*info != 0) {
176         i__1 = -(*info);
177         xerbla_("DORM2L", &i__1);
178         return 0;
179     }
180
181 /*     Quick return if possible */
182
183     if (*m == 0 || *n == 0 || *k == 0) {
184         return 0;
185     }
186
187     if (left && notran || ! left && ! notran) {
188         i1 = 1;
189         i2 = *k;
190         i3 = 1;
191     } else {
192         i1 = *k;
193         i2 = 1;
194         i3 = -1;
195     }
196
197     if (left) {
198         ni = *n;
199     } else {
200         mi = *m;
201     }
202
203     i__1 = i2;
204     i__2 = i3;
205     for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
206         if (left) {
207
208 /*           H(i) is applied to C(1:m-k+i,1:n) */
209
210             mi = *m - *k + i__;
211         } else {
212
213 /*           H(i) is applied to C(1:m,1:n-k+i) */
214
215             ni = *n - *k + i__;
216         }
217
218 /*        Apply H(i) */
219
220         aii = a[nq - *k + i__ + i__ * a_dim1];
221         a[nq - *k + i__ + i__ * a_dim1] = 1.;
222         dlarf_(side, &mi, &ni, &a[i__ * a_dim1 + 1], &c__1, &tau[i__], &c__[
223                 c_offset], ldc, &work[1]);
224         a[nq - *k + i__ + i__ * a_dim1] = aii;
225 /* L10: */
226     }
227     return 0;
228
229 /*     End of DORM2L */
230
231 } /* dorm2l_ */