Coverage Report

Created: 2025-09-20 18:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/contrib/openblas/lapack-netlib/SRC/sgelq2.c
Line
Count
Source
1
#include <math.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include <complex.h>
6
#ifdef complex
7
#undef complex
8
#endif
9
#ifdef I
10
#undef I
11
#endif
12
13
#if defined(_WIN64)
14
typedef long long BLASLONG;
15
typedef unsigned long long BLASULONG;
16
#else
17
typedef long BLASLONG;
18
typedef unsigned long BLASULONG;
19
#endif
20
21
#ifdef LAPACK_ILP64
22
typedef BLASLONG blasint;
23
#if defined(_WIN64)
24
#define blasabs(x) llabs(x)
25
#else
26
#define blasabs(x) labs(x)
27
#endif
28
#else
29
typedef int blasint;
30
#define blasabs(x) abs(x)
31
#endif
32
33
typedef blasint integer;
34
35
typedef unsigned int uinteger;
36
typedef char *address;
37
typedef short int shortint;
38
typedef float real;
39
typedef double doublereal;
40
typedef struct { real r, i; } complex;
41
typedef struct { doublereal r, i; } doublecomplex;
42
#ifdef _MSC_VER
43
static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44
static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45
static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46
static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
47
#else
48
0
static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49
0
static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50
0
static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51
0
static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
52
#endif
53
#define pCf(z) (*_pCf(z))
54
#define pCd(z) (*_pCd(z))
55
typedef char integer1;
56
57
#define TRUE_ (1)
58
#define FALSE_ (0)
59
60
/* Extern is for use with -E */
61
#ifndef Extern
62
#define Extern extern
63
#endif
64
65
/* I/O stuff */
66
67
typedef int flag;
68
typedef int ftnlen;
69
typedef int ftnint;
70
71
/*external read, write*/
72
typedef struct
73
{ flag cierr;
74
  ftnint ciunit;
75
  flag ciend;
76
  char *cifmt;
77
  ftnint cirec;
78
} cilist;
79
80
/*internal read, write*/
81
typedef struct
82
{ flag icierr;
83
  char *iciunit;
84
  flag iciend;
85
  char *icifmt;
86
  ftnint icirlen;
87
  ftnint icirnum;
88
} icilist;
89
90
/*open*/
91
typedef struct
92
{ flag oerr;
93
  ftnint ounit;
94
  char *ofnm;
95
  ftnlen ofnmlen;
96
  char *osta;
97
  char *oacc;
98
  char *ofm;
99
  ftnint orl;
100
  char *oblnk;
101
} olist;
102
103
/*close*/
104
typedef struct
105
{ flag cerr;
106
  ftnint cunit;
107
  char *csta;
108
} cllist;
109
110
/*rewind, backspace, endfile*/
111
typedef struct
112
{ flag aerr;
113
  ftnint aunit;
114
} alist;
115
116
/* inquire */
117
typedef struct
118
{ flag inerr;
119
  ftnint inunit;
120
  char *infile;
121
  ftnlen infilen;
122
  ftnint  *inex;  /*parameters in standard's order*/
123
  ftnint  *inopen;
124
  ftnint  *innum;
125
  ftnint  *innamed;
126
  char  *inname;
127
  ftnlen  innamlen;
128
  char  *inacc;
129
  ftnlen  inacclen;
130
  char  *inseq;
131
  ftnlen  inseqlen;
132
  char  *indir;
133
  ftnlen  indirlen;
134
  char  *infmt;
135
  ftnlen  infmtlen;
136
  char  *inform;
137
  ftnint  informlen;
138
  char  *inunf;
139
  ftnlen  inunflen;
140
  ftnint  *inrecl;
141
  ftnint  *innrec;
142
  char  *inblank;
143
  ftnlen  inblanklen;
144
} inlist;
145
146
#define VOID void
147
148
union Multitype { /* for multiple entry points */
149
  integer1 g;
150
  shortint h;
151
  integer i;
152
  /* longint j; */
153
  real r;
154
  doublereal d;
155
  complex c;
156
  doublecomplex z;
157
  };
158
159
typedef union Multitype Multitype;
160
161
struct Vardesc {  /* for Namelist */
162
  char *name;
163
  char *addr;
164
  ftnlen *dims;
165
  int  type;
166
  };
167
typedef struct Vardesc Vardesc;
168
169
struct Namelist {
170
  char *name;
171
  Vardesc **vars;
172
  int nvars;
173
  };
174
typedef struct Namelist Namelist;
175
176
#define abs(x) ((x) >= 0 ? (x) : -(x))
177
#define dabs(x) (fabs(x))
178
0
#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
179
0
#define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
180
#define dmin(a,b) (f2cmin(a,b))
181
#define dmax(a,b) (f2cmax(a,b))
182
#define bit_test(a,b) ((a) >> (b) & 1)
183
#define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
184
#define bit_set(a,b)  ((a) |  ((uinteger)1 << (b)))
185
186
#define abort_() { sig_die("Fortran abort routine called", 1); }
187
#define c_abs(z) (cabsf(Cf(z)))
188
#define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
189
#ifdef _MSC_VER
190
#define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
191
#define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
192
#else
193
#define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
194
#define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
195
#endif
196
#define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
197
#define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
198
#define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
199
//#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
200
#define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
201
#define d_abs(x) (fabs(*(x)))
202
#define d_acos(x) (acos(*(x)))
203
#define d_asin(x) (asin(*(x)))
204
#define d_atan(x) (atan(*(x)))
205
#define d_atn2(x, y) (atan2(*(x),*(y)))
206
#define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
207
#define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
208
#define d_cos(x) (cos(*(x)))
209
#define d_cosh(x) (cosh(*(x)))
210
#define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
211
#define d_exp(x) (exp(*(x)))
212
#define d_imag(z) (cimag(Cd(z)))
213
#define r_imag(z) (cimagf(Cf(z)))
214
#define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
215
#define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
216
#define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
217
#define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
218
#define d_log(x) (log(*(x)))
219
#define d_mod(x, y) (fmod(*(x), *(y)))
220
#define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
221
#define d_nint(x) u_nint(*(x))
222
#define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
223
#define d_sign(a,b) u_sign(*(a),*(b))
224
#define r_sign(a,b) u_sign(*(a),*(b))
225
#define d_sin(x) (sin(*(x)))
226
#define d_sinh(x) (sinh(*(x)))
227
#define d_sqrt(x) (sqrt(*(x)))
228
#define d_tan(x) (tan(*(x)))
229
#define d_tanh(x) (tanh(*(x)))
230
#define i_abs(x) abs(*(x))
231
#define i_dnnt(x) ((integer)u_nint(*(x)))
232
#define i_len(s, n) (n)
233
#define i_nint(x) ((integer)u_nint(*(x)))
234
#define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
235
#define s_cat(lpp, rpp, rnp, np, llp) {   ftnlen i, nc, ll; char *f__rp, *lp;   ll = (llp); lp = (lpp);   for(i=0; i < (int)*(np); ++i) {           nc = ll;          if((rnp)[i] < nc) nc = (rnp)[i];          ll -= nc;           f__rp = (rpp)[i];           while(--nc >= 0) *lp++ = *(f__rp)++;         }  while(--ll >= 0) *lp++ = ' '; }
236
#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
237
#define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
238
#define sig_die(s, kill) { exit(1); }
239
#define s_stop(s, n) {exit(0);}
240
#define z_abs(z) (cabs(Cd(z)))
241
#define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
242
#define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
243
#define myexit_() break;
244
#define mycycle() continue;
245
#define myceiling(w) {ceil(w)}
246
#define myhuge(w) {HUGE_VAL}
247
//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
248
#define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
249
250
/*  -- translated by f2c (version 20000121).
251
   You must link the resulting object file with the libraries:
252
  -lf2c -lm   (in that order)
253
*/
254
255
256
257
258
/* > \brief \b SGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorit
259
hm. */
260
261
/*  =========== DOCUMENTATION =========== */
262
263
/* Online html documentation available at */
264
/*            http://www.netlib.org/lapack/explore-html/ */
265
266
/* > \htmlonly */
267
/* > Download SGELQ2 + dependencies */
268
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgelq2.
269
f"> */
270
/* > [TGZ]</a> */
271
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgelq2.
272
f"> */
273
/* > [ZIP]</a> */
274
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgelq2.
275
f"> */
276
/* > [TXT]</a> */
277
/* > \endhtmlonly */
278
279
/*  Definition: */
280
/*  =========== */
281
282
/*       SUBROUTINE SGELQ2( M, N, A, LDA, TAU, WORK, INFO ) */
283
284
/*       INTEGER            INFO, LDA, M, N */
285
/*       REAL               A( LDA, * ), TAU( * ), WORK( * ) */
286
287
288
/* > \par Purpose: */
289
/*  ============= */
290
/* > */
291
/* > \verbatim */
292
/* > */
293
/* > SGELQ2 computes an LQ factorization of a real m-by-n matrix A: */
294
/* > */
295
/* >    A = ( L 0 ) *  Q */
296
/* > */
297
/* > where: */
298
/* > */
299
/* >    Q is a n-by-n orthogonal matrix; */
300
/* >    L is an lower-triangular m-by-m matrix; */
301
/* >    0 is a m-by-(n-m) zero matrix, if m < n. */
302
/* > */
303
/* > \endverbatim */
304
305
/*  Arguments: */
306
/*  ========== */
307
308
/* > \param[in] M */
309
/* > \verbatim */
310
/* >          M is INTEGER */
311
/* >          The number of rows of the matrix A.  M >= 0. */
312
/* > \endverbatim */
313
/* > */
314
/* > \param[in] N */
315
/* > \verbatim */
316
/* >          N is INTEGER */
317
/* >          The number of columns of the matrix A.  N >= 0. */
318
/* > \endverbatim */
319
/* > */
320
/* > \param[in,out] A */
321
/* > \verbatim */
322
/* >          A is REAL array, dimension (LDA,N) */
323
/* >          On entry, the m by n matrix A. */
324
/* >          On exit, the elements on and below the diagonal of the array */
325
/* >          contain the m by f2cmin(m,n) lower trapezoidal matrix L (L is */
326
/* >          lower triangular if m <= n); the elements above the diagonal, */
327
/* >          with the array TAU, represent the orthogonal matrix Q as a */
328
/* >          product of elementary reflectors (see Further Details). */
329
/* > \endverbatim */
330
/* > */
331
/* > \param[in] LDA */
332
/* > \verbatim */
333
/* >          LDA is INTEGER */
334
/* >          The leading dimension of the array A.  LDA >= f2cmax(1,M). */
335
/* > \endverbatim */
336
/* > */
337
/* > \param[out] TAU */
338
/* > \verbatim */
339
/* >          TAU is REAL array, dimension (f2cmin(M,N)) */
340
/* >          The scalar factors of the elementary reflectors (see Further */
341
/* >          Details). */
342
/* > \endverbatim */
343
/* > */
344
/* > \param[out] WORK */
345
/* > \verbatim */
346
/* >          WORK is REAL array, dimension (M) */
347
/* > \endverbatim */
348
/* > */
349
/* > \param[out] INFO */
350
/* > \verbatim */
351
/* >          INFO is INTEGER */
352
/* >          = 0: successful exit */
353
/* >          < 0: if INFO = -i, the i-th argument had an illegal value */
354
/* > \endverbatim */
355
356
/*  Authors: */
357
/*  ======== */
358
359
/* > \author Univ. of Tennessee */
360
/* > \author Univ. of California Berkeley */
361
/* > \author Univ. of Colorado Denver */
362
/* > \author NAG Ltd. */
363
364
/* > \date November 2019 */
365
366
/* > \ingroup realGEcomputational */
367
368
/* > \par Further Details: */
369
/*  ===================== */
370
/* > */
371
/* > \verbatim */
372
/* > */
373
/* >  The matrix Q is represented as a product of elementary reflectors */
374
/* > */
375
/* >     Q = H(k) . . . H(2) H(1), where k = f2cmin(m,n). */
376
/* > */
377
/* >  Each H(i) has the form */
378
/* > */
379
/* >     H(i) = I - tau * v * v**T */
380
/* > */
381
/* >  where tau is a real scalar, and v is a real vector with */
382
/* >  v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */
383
/* >  and tau in TAU(i). */
384
/* > \endverbatim */
385
/* > */
386
/*  ===================================================================== */
387
/* Subroutine */ void sgelq2_(integer *m, integer *n, real *a, integer *lda, 
388
  real *tau, real *work, integer *info)
389
0
{
390
    /* System generated locals */
391
0
    integer a_dim1, a_offset, i__1, i__2, i__3;
392
393
    /* Local variables */
394
0
    integer i__, k;
395
0
    extern /* Subroutine */ void slarf_(char *, integer *, integer *, real *, 
396
0
      integer *, real *, real *, integer *, real *);
397
0
    extern int xerbla_(char *, integer *, ftnlen);
398
0
    extern void slarfg_(integer *, real *, real *, integer *, real *);
399
0
    real aii;
400
401
402
/*  -- LAPACK computational routine (version 3.9.0) -- */
403
/*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
404
/*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
405
/*     November 2019 */
406
407
408
/*  ===================================================================== */
409
410
411
/*     Test the input arguments */
412
413
    /* Parameter adjustments */
414
0
    a_dim1 = *lda;
415
0
    a_offset = 1 + a_dim1 * 1;
416
0
    a -= a_offset;
417
0
    --tau;
418
0
    --work;
419
420
    /* Function Body */
421
0
    *info = 0;
422
0
    if (*m < 0) {
423
0
  *info = -1;
424
0
    } else if (*n < 0) {
425
0
  *info = -2;
426
0
    } else if (*lda < f2cmax(1,*m)) {
427
0
  *info = -4;
428
0
    }
429
0
    if (*info != 0) {
430
0
  i__1 = -(*info);
431
0
  xerbla_("SGELQ2", &i__1, (ftnlen)6);
432
0
  return;
433
0
    }
434
435
0
    k = f2cmin(*m,*n);
436
437
0
    i__1 = k;
438
0
    for (i__ = 1; i__ <= i__1; ++i__) {
439
440
/*        Generate elementary reflector H(i) to annihilate A(i,i+1:n) */
441
442
0
  i__2 = *n - i__ + 1;
443
/* Computing MIN */
444
0
  i__3 = i__ + 1;
445
0
  slarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + f2cmin(i__3,*n) * a_dim1]
446
0
    , lda, &tau[i__]);
447
0
  if (i__ < *m) {
448
449
/*           Apply H(i) to A(i+1:m,i:n) from the right */
450
451
0
      aii = a[i__ + i__ * a_dim1];
452
0
      a[i__ + i__ * a_dim1] = 1.f;
453
0
      i__2 = *m - i__;
454
0
      i__3 = *n - i__ + 1;
455
0
      slarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[
456
0
        i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
457
0
      a[i__ + i__ * a_dim1] = aii;
458
0
  }
459
/* L10: */
460
0
    }
461
0
    return;
462
463
/*     End of SGELQ2 */
464
465
0
} /* sgelq2_ */
466