File: cgbbrd.c

package info (click to toggle)
libflame 5.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 162,052 kB
  • sloc: ansic: 750,080; fortran: 404,344; makefile: 8,133; sh: 5,458; python: 937; pascal: 144; perl: 66
file content (770 lines) | stat: -rw-r--r-- 26,850 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
/* ../netlib/cgbbrd.f -- translated by f2c (version 20100827). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib;
 on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */
#include "FLA_f2c.h" /* Table of constant values */
static complex c_b1 =
{
    0.f,0.f
}
;
static complex c_b2 =
{
    1.f,0.f
}
;
static integer c__1 = 1;
/* > \brief \b CGBBRD */
/* =========== DOCUMENTATION =========== */
/* Online html documentation available at */
/* http://www.netlib.org/lapack/explore-html/ */
/* > \htmlonly */
/* > Download CGBBRD + dependencies */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbbrd. f"> */
/* > [TGZ]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbbrd. f"> */
/* > [ZIP]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbbrd. f"> */
/* > [TXT]</a> */
/* > \endhtmlonly */
/* Definition: */
/* =========== */
/* SUBROUTINE CGBBRD( VECT, M, N, NCC, KL, KU, AB, LDAB, D, E, Q, */
/* LDQ, PT, LDPT, C, LDC, WORK, RWORK, INFO ) */
/* .. Scalar Arguments .. */
/* CHARACTER VECT */
/* INTEGER INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC */
/* .. */
/* .. Array Arguments .. */
/* REAL D( * ), E( * ), RWORK( * ) */
/* COMPLEX AB( LDAB, * ), C( LDC, * ), PT( LDPT, * ), */
/* $ Q( LDQ, * ), WORK( * ) */
/* .. */
/* > \par Purpose: */
/* ============= */
/* > */
/* > \verbatim */
/* > */
/* > CGBBRD reduces a complex general m-by-n band matrix A to real upper */
/* > bidiagonal form B by a unitary transformation: Q**H * A * P = B. */
/* > */
/* > The routine computes B, and optionally forms Q or P**H, or computes */
/* > Q**H*C for a given matrix C. */
/* > \endverbatim */
/* Arguments: */
/* ========== */
/* > \param[in] VECT */
/* > \verbatim */
/* > VECT is CHARACTER*1 */
/* > Specifies whether or not the matrices Q and P**H are to be */
/* > formed. */
/* > = 'N': do not form Q or P**H;
*/
/* > = 'Q': form Q only;
*/
/* > = 'P': form P**H only;
*/
/* > = 'B': form both. */
/* > \endverbatim */
/* > */
/* > \param[in] M */
/* > \verbatim */
/* > M is INTEGER */
/* > The number of rows of the matrix A. M >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] N */
/* > \verbatim */
/* > N is INTEGER */
/* > The number of columns of the matrix A. N >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] NCC */
/* > \verbatim */
/* > NCC is INTEGER */
/* > The number of columns of the matrix C. NCC >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] KL */
/* > \verbatim */
/* > KL is INTEGER */
/* > The number of subdiagonals of the matrix A. KL >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] KU */
/* > \verbatim */
/* > KU is INTEGER */
/* > The number of superdiagonals of the matrix A. KU >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in,out] AB */
/* > \verbatim */
/* > AB is COMPLEX array, dimension (LDAB,N) */
/* > On entry, the m-by-n band matrix A, stored in rows 1 to */
/* > KL+KU+1. The j-th column of A is stored in the j-th column of */
/* > the array AB as follows: */
/* > AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl). */
/* > On exit, A is overwritten by values generated during the */
/* > reduction. */
/* > \endverbatim */
/* > */
/* > \param[in] LDAB */
/* > \verbatim */
/* > LDAB is INTEGER */
/* > The leading dimension of the array A. LDAB >= KL+KU+1. */
/* > \endverbatim */
/* > */
/* > \param[out] D */
/* > \verbatim */
/* > D is REAL array, dimension (min(M,N)) */
/* > The diagonal elements of the bidiagonal matrix B. */
/* > \endverbatim */
/* > */
/* > \param[out] E */
/* > \verbatim */
/* > E is REAL array, dimension (min(M,N)-1) */
/* > The superdiagonal elements of the bidiagonal matrix B. */
/* > \endverbatim */
/* > */
/* > \param[out] Q */
/* > \verbatim */
/* > Q is COMPLEX array, dimension (LDQ,M) */
/* > If VECT = 'Q' or 'B', the m-by-m unitary matrix Q. */
/* > If VECT = 'N' or 'P', the array Q is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[in] LDQ */
/* > \verbatim */
/* > LDQ is INTEGER */
/* > The leading dimension of the array Q. */
/* > LDQ >= max(1,M) if VECT = 'Q' or 'B';
LDQ >= 1 otherwise. */
/* > \endverbatim */
/* > */
/* > \param[out] PT */
/* > \verbatim */
/* > PT is COMPLEX array, dimension (LDPT,N) */
/* > If VECT = 'P' or 'B', the n-by-n unitary matrix P'. */
/* > If VECT = 'N' or 'Q', the array PT is not referenced. */
/* > \endverbatim */
/* > */
/* > \param[in] LDPT */
/* > \verbatim */
/* > LDPT is INTEGER */
/* > The leading dimension of the array PT. */
/* > LDPT >= max(1,N) if VECT = 'P' or 'B';
LDPT >= 1 otherwise. */
/* > \endverbatim */
/* > */
/* > \param[in,out] C */
/* > \verbatim */
/* > C is COMPLEX array, dimension (LDC,NCC) */
/* > On entry, an m-by-ncc matrix C. */
/* > On exit, C is overwritten by Q**H*C. */
/* > C is not referenced if NCC = 0. */
/* > \endverbatim */
/* > */
/* > \param[in] LDC */
/* > \verbatim */
/* > LDC is INTEGER */
/* > The leading dimension of the array C. */
/* > LDC >= max(1,M) if NCC > 0;
LDC >= 1 if NCC = 0. */
/* > \endverbatim */
/* > */
/* > \param[out] WORK */
/* > \verbatim */
/* > WORK is COMPLEX array, dimension (max(M,N)) */
/* > \endverbatim */
/* > */
/* > \param[out] RWORK */
/* > \verbatim */
/* > RWORK is REAL array, dimension (max(M,N)) */
/* > \endverbatim */
/* > */
/* > \param[out] INFO */
/* > \verbatim */
/* > INFO is INTEGER */
/* > = 0: successful exit. */
/* > < 0: if INFO = -i, the i-th argument had an illegal value. */
/* > \endverbatim */
/* Authors: */
/* ======== */
/* > \author Univ. of Tennessee */
/* > \author Univ. of California Berkeley */
/* > \author Univ. of Colorado Denver */
/* > \author NAG Ltd. */
/* > \date November 2011 */
/* > \ingroup complexGBcomputational */
/* ===================================================================== */
/* Subroutine */
int cgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, integer *ku, complex *ab, integer *ldab, real *d__, real *e, complex *q, integer *ldq, complex *pt, integer *ldpt, complex *c__, integer *ldc, complex *work, real *rwork, integer *info)
{
    /* System generated locals */
    integer ab_dim1, ab_offset, c_dim1, c_offset, pt_dim1, pt_offset, q_dim1, q_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7;
    complex q__1, q__2, q__3;
    /* Builtin functions */
    void r_cnjg(complex *, complex *);
    double c_abs(complex *);
    /* Local variables */
    integer i__, j, l;
    complex t;
    integer j1, j2, kb;
    complex ra, rb;
    real rc;
    integer kk, ml, nr, mu;
    complex rs;
    integer kb1, ml0, mu0, klm, kun, nrt, klu1, inca;
    real abst;
    extern /* Subroutine */
    int crot_(integer *, complex *, integer *, complex *, integer *, real *, complex *), cscal_(integer *, complex *, complex *, integer *);
    extern logical lsame_(char *, char *);
    logical wantb, wantc;
    integer minmn;
    logical wantq;
    extern /* Subroutine */
    int claset_(char *, integer *, integer *, complex *, complex *, complex *, integer *), clartg_(complex *, complex *, real *, complex *, complex *), xerbla_(char *, integer *), clargv_(integer *, complex *, integer *, complex *, integer *, real *, integer *), clartv_(integer *, complex *, integer *, complex *, integer *, real *, complex *, integer *);
    logical wantpt;
    /* -- LAPACK computational routine (version 3.4.0) -- */
    /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
    /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
    /* November 2011 */
    /* .. Scalar Arguments .. */
    /* .. */
    /* .. Array Arguments .. */
    /* .. */
    /* ===================================================================== */
    /* .. Parameters .. */
    /* .. */
    /* .. Local Scalars .. */
    /* .. */
    /* .. External Subroutines .. */
    /* .. */
    /* .. Intrinsic Functions .. */
    /* .. */
    /* .. External Functions .. */
    /* .. */
    /* .. Executable Statements .. */
    /* Test the input parameters */
    /* Parameter adjustments */
    ab_dim1 = *ldab;
    ab_offset = 1 + ab_dim1;
    ab -= ab_offset;
    --d__;
    --e;
    q_dim1 = *ldq;
    q_offset = 1 + q_dim1;
    q -= q_offset;
    pt_dim1 = *ldpt;
    pt_offset = 1 + pt_dim1;
    pt -= pt_offset;
    c_dim1 = *ldc;
    c_offset = 1 + c_dim1;
    c__ -= c_offset;
    --work;
    --rwork;
    /* Function Body */
    wantb = lsame_(vect, "B");
    wantq = lsame_(vect, "Q") || wantb;
    wantpt = lsame_(vect, "P") || wantb;
    wantc = *ncc > 0;
    klu1 = *kl + *ku + 1;
    *info = 0;
    if (! wantq && ! wantpt && ! lsame_(vect, "N"))
    {
        *info = -1;
    }
    else if (*m < 0)
    {
        *info = -2;
    }
    else if (*n < 0)
    {
        *info = -3;
    }
    else if (*ncc < 0)
    {
        *info = -4;
    }
    else if (*kl < 0)
    {
        *info = -5;
    }
    else if (*ku < 0)
    {
        *info = -6;
    }
    else if (*ldab < klu1)
    {
        *info = -8;
    }
    else if (*ldq < 1 || wantq && *ldq < max(1,*m))
    {
        *info = -12;
    }
    else if (*ldpt < 1 || wantpt && *ldpt < max(1,*n))
    {
        *info = -14;
    }
    else if (*ldc < 1 || wantc && *ldc < max(1,*m))
    {
        *info = -16;
    }
    if (*info != 0)
    {
        i__1 = -(*info);
        xerbla_("CGBBRD", &i__1);
        return 0;
    }
    /* Initialize Q and P**H to the unit matrix, if needed */
    if (wantq)
    {
        claset_("Full", m, m, &c_b1, &c_b2, &q[q_offset], ldq);
    }
    if (wantpt)
    {
        claset_("Full", n, n, &c_b1, &c_b2, &pt[pt_offset], ldpt);
    }
    /* Quick return if possible. */
    if (*m == 0 || *n == 0)
    {
        return 0;
    }
    minmn = min(*m,*n);
    if (*kl + *ku > 1)
    {
        /* Reduce to upper bidiagonal form if KU > 0;
        if KU = 0, reduce */
        /* first to lower bidiagonal form and then transform to upper */
        /* bidiagonal */
        if (*ku > 0)
        {
            ml0 = 1;
            mu0 = 2;
        }
        else
        {
            ml0 = 2;
            mu0 = 1;
        }
        /* Wherever possible, plane rotations are generated and applied in */
        /* vector operations of length NR over the index set J1:J2:KLU1. */
        /* The complex sines of the plane rotations are stored in WORK, */
        /* and the real cosines in RWORK. */
        /* Computing MIN */
        i__1 = *m - 1;
        klm = min(i__1,*kl);
        /* Computing MIN */
        i__1 = *n - 1;
        kun = min(i__1,*ku);
        kb = klm + kun;
        kb1 = kb + 1;
        inca = kb1 * *ldab;
        nr = 0;
        j1 = klm + 2;
        j2 = 1 - kun;
        i__1 = minmn;
        for (i__ = 1;
                i__ <= i__1;
                ++i__)
        {
            /* Reduce i-th column and i-th row of matrix to bidiagonal form */
            ml = klm + 1;
            mu = kun + 1;
            i__2 = kb;
            for (kk = 1;
                    kk <= i__2;
                    ++kk)
            {
                j1 += kb;
                j2 += kb;
                /* generate plane rotations to annihilate nonzero elements */
                /* which have been created below the band */
                if (nr > 0)
                {
                    clargv_(&nr, &ab[klu1 + (j1 - klm - 1) * ab_dim1], &inca, &work[j1], &kb1, &rwork[j1], &kb1);
                }
                /* apply plane rotations from the left */
                i__3 = kb;
                for (l = 1;
                        l <= i__3;
                        ++l)
                {
                    if (j2 - klm + l - 1 > *n)
                    {
                        nrt = nr - 1;
                    }
                    else
                    {
                        nrt = nr;
                    }
                    if (nrt > 0)
                    {
                        clartv_(&nrt, &ab[klu1 - l + (j1 - klm + l - 1) * ab_dim1], &inca, &ab[klu1 - l + 1 + (j1 - klm + l - 1) * ab_dim1], &inca, &rwork[j1], &work[ j1], &kb1);
                    }
                    /* L10: */
                }
                if (ml > ml0)
                {
                    if (ml <= *m - i__ + 1)
                    {
                        /* generate plane rotation to annihilate a(i+ml-1,i) */
                        /* within the band, and apply rotation from the left */
                        clartg_(&ab[*ku + ml - 1 + i__ * ab_dim1], &ab[*ku + ml + i__ * ab_dim1], &rwork[i__ + ml - 1], & work[i__ + ml - 1], &ra);
                        i__3 = *ku + ml - 1 + i__ * ab_dim1;
                        ab[i__3].r = ra.r;
                        ab[i__3].i = ra.i; // , expr subst
                        if (i__ < *n)
                        {
                            /* Computing MIN */
                            i__4 = *ku + ml - 2;
                            i__5 = *n - i__; // , expr subst
                            i__3 = min(i__4,i__5);
                            i__6 = *ldab - 1;
                            i__7 = *ldab - 1;
                            crot_(&i__3, &ab[*ku + ml - 2 + (i__ + 1) * ab_dim1], &i__6, &ab[*ku + ml - 1 + (i__ + 1) * ab_dim1], &i__7, &rwork[i__ + ml - 1], &work[i__ + ml - 1]);
                        }
                    }
                    ++nr;
                    j1 -= kb1;
                }
                if (wantq)
                {
                    /* accumulate product of plane rotations in Q */
                    i__3 = j2;
                    i__4 = kb1;
                    for (j = j1;
                            i__4 < 0 ? j >= i__3 : j <= i__3;
                            j += i__4)
                    {
                        r_cnjg(&q__1, &work[j]);
                        crot_(m, &q[(j - 1) * q_dim1 + 1], &c__1, &q[j * q_dim1 + 1], &c__1, &rwork[j], &q__1);
                        /* L20: */
                    }
                }
                if (wantc)
                {
                    /* apply plane rotations to C */
                    i__4 = j2;
                    i__3 = kb1;
                    for (j = j1;
                            i__3 < 0 ? j >= i__4 : j <= i__4;
                            j += i__3)
                    {
                        crot_(ncc, &c__[j - 1 + c_dim1], ldc, &c__[j + c_dim1] , ldc, &rwork[j], &work[j]);
                        /* L30: */
                    }
                }
                if (j2 + kun > *n)
                {
                    /* adjust J2 to keep within the bounds of the matrix */
                    --nr;
                    j2 -= kb1;
                }
                i__3 = j2;
                i__4 = kb1;
                for (j = j1;
                        i__4 < 0 ? j >= i__3 : j <= i__3;
                        j += i__4)
                {
                    /* create nonzero element a(j-1,j+ku) above the band */
                    /* and store it in WORK(n+1:2*n) */
                    i__5 = j + kun;
                    i__6 = j;
                    i__7 = (j + kun) * ab_dim1 + 1;
                    q__1.r = work[i__6].r * ab[i__7].r - work[i__6].i * ab[ i__7].i;
                    q__1.i = work[i__6].r * ab[i__7].i + work[i__6].i * ab[i__7].r; // , expr subst
                    work[i__5].r = q__1.r;
                    work[i__5].i = q__1.i; // , expr subst
                    i__5 = (j + kun) * ab_dim1 + 1;
                    i__6 = j;
                    i__7 = (j + kun) * ab_dim1 + 1;
                    q__1.r = rwork[i__6] * ab[i__7].r;
                    q__1.i = rwork[i__6] * ab[i__7].i; // , expr subst
                    ab[i__5].r = q__1.r;
                    ab[i__5].i = q__1.i; // , expr subst
                    /* L40: */
                }
                /* generate plane rotations to annihilate nonzero elements */
                /* which have been generated above the band */
                if (nr > 0)
                {
                    clargv_(&nr, &ab[(j1 + kun - 1) * ab_dim1 + 1], &inca, & work[j1 + kun], &kb1, &rwork[j1 + kun], &kb1);
                }
                /* apply plane rotations from the right */
                i__4 = kb;
                for (l = 1;
                        l <= i__4;
                        ++l)
                {
                    if (j2 + l - 1 > *m)
                    {
                        nrt = nr - 1;
                    }
                    else
                    {
                        nrt = nr;
                    }
                    if (nrt > 0)
                    {
                        clartv_(&nrt, &ab[l + 1 + (j1 + kun - 1) * ab_dim1], & inca, &ab[l + (j1 + kun) * ab_dim1], &inca, & rwork[j1 + kun], &work[j1 + kun], &kb1);
                    }
                    /* L50: */
                }
                if (ml == ml0 && mu > mu0)
                {
                    if (mu <= *n - i__ + 1)
                    {
                        /* generate plane rotation to annihilate a(i,i+mu-1) */
                        /* within the band, and apply rotation from the right */
                        clartg_(&ab[*ku - mu + 3 + (i__ + mu - 2) * ab_dim1], &ab[*ku - mu + 2 + (i__ + mu - 1) * ab_dim1], &rwork[i__ + mu - 1], &work[i__ + mu - 1], & ra);
                        i__4 = *ku - mu + 3 + (i__ + mu - 2) * ab_dim1;
                        ab[i__4].r = ra.r;
                        ab[i__4].i = ra.i; // , expr subst
                        /* Computing MIN */
                        i__3 = *kl + mu - 2;
                        i__5 = *m - i__; // , expr subst
                        i__4 = min(i__3,i__5);
                        crot_(&i__4, &ab[*ku - mu + 4 + (i__ + mu - 2) * ab_dim1], &c__1, &ab[*ku - mu + 3 + (i__ + mu - 1) * ab_dim1], &c__1, &rwork[i__ + mu - 1], &work[i__ + mu - 1]);
                    }
                    ++nr;
                    j1 -= kb1;
                }
                if (wantpt)
                {
                    /* accumulate product of plane rotations in P**H */
                    i__4 = j2;
                    i__3 = kb1;
                    for (j = j1;
                            i__3 < 0 ? j >= i__4 : j <= i__4;
                            j += i__3)
                    {
                        r_cnjg(&q__1, &work[j + kun]);
                        crot_(n, &pt[j + kun - 1 + pt_dim1], ldpt, &pt[j + kun + pt_dim1], ldpt, &rwork[j + kun], &q__1);
                        /* L60: */
                    }
                }
                if (j2 + kb > *m)
                {
                    /* adjust J2 to keep within the bounds of the matrix */
                    --nr;
                    j2 -= kb1;
                }
                i__3 = j2;
                i__4 = kb1;
                for (j = j1;
                        i__4 < 0 ? j >= i__3 : j <= i__3;
                        j += i__4)
                {
                    /* create nonzero element a(j+kl+ku,j+ku-1) below the */
                    /* band and store it in WORK(1:n) */
                    i__5 = j + kb;
                    i__6 = j + kun;
                    i__7 = klu1 + (j + kun) * ab_dim1;
                    q__1.r = work[i__6].r * ab[i__7].r - work[i__6].i * ab[ i__7].i;
                    q__1.i = work[i__6].r * ab[i__7].i + work[i__6].i * ab[i__7].r; // , expr subst
                    work[i__5].r = q__1.r;
                    work[i__5].i = q__1.i; // , expr subst
                    i__5 = klu1 + (j + kun) * ab_dim1;
                    i__6 = j + kun;
                    i__7 = klu1 + (j + kun) * ab_dim1;
                    q__1.r = rwork[i__6] * ab[i__7].r;
                    q__1.i = rwork[i__6] * ab[i__7].i; // , expr subst
                    ab[i__5].r = q__1.r;
                    ab[i__5].i = q__1.i; // , expr subst
                    /* L70: */
                }
                if (ml > ml0)
                {
                    --ml;
                }
                else
                {
                    --mu;
                }
                /* L80: */
            }
            /* L90: */
        }
    }
    if (*ku == 0 && *kl > 0)
    {
        /* A has been reduced to complex lower bidiagonal form */
        /* Transform lower bidiagonal form to upper bidiagonal by applying */
        /* plane rotations from the left, overwriting superdiagonal */
        /* elements on subdiagonal elements */
        /* Computing MIN */
        i__2 = *m - 1;
        i__1 = min(i__2,*n);
        for (i__ = 1;
                i__ <= i__1;
                ++i__)
        {
            clartg_(&ab[i__ * ab_dim1 + 1], &ab[i__ * ab_dim1 + 2], &rc, &rs, &ra);
            i__2 = i__ * ab_dim1 + 1;
            ab[i__2].r = ra.r;
            ab[i__2].i = ra.i; // , expr subst
            if (i__ < *n)
            {
                i__2 = i__ * ab_dim1 + 2;
                i__4 = (i__ + 1) * ab_dim1 + 1;
                q__1.r = rs.r * ab[i__4].r - rs.i * ab[i__4].i;
                q__1.i = rs.r * ab[i__4].i + rs.i * ab[i__4].r; // , expr subst
                ab[i__2].r = q__1.r;
                ab[i__2].i = q__1.i; // , expr subst
                i__2 = (i__ + 1) * ab_dim1 + 1;
                i__4 = (i__ + 1) * ab_dim1 + 1;
                q__1.r = rc * ab[i__4].r;
                q__1.i = rc * ab[i__4].i; // , expr subst
                ab[i__2].r = q__1.r;
                ab[i__2].i = q__1.i; // , expr subst
            }
            if (wantq)
            {
                r_cnjg(&q__1, &rs);
                crot_(m, &q[i__ * q_dim1 + 1], &c__1, &q[(i__ + 1) * q_dim1 + 1], &c__1, &rc, &q__1);
            }
            if (wantc)
            {
                crot_(ncc, &c__[i__ + c_dim1], ldc, &c__[i__ + 1 + c_dim1], ldc, &rc, &rs);
            }
            /* L100: */
        }
    }
    else
    {
        /* A has been reduced to complex upper bidiagonal form or is */
        /* diagonal */
        if (*ku > 0 && *m < *n)
        {
            /* Annihilate a(m,m+1) by applying plane rotations from the */
            /* right */
            i__1 = *ku + (*m + 1) * ab_dim1;
            rb.r = ab[i__1].r;
            rb.i = ab[i__1].i; // , expr subst
            for (i__ = *m;
                    i__ >= 1;
                    --i__)
            {
                clartg_(&ab[*ku + 1 + i__ * ab_dim1], &rb, &rc, &rs, &ra);
                i__1 = *ku + 1 + i__ * ab_dim1;
                ab[i__1].r = ra.r;
                ab[i__1].i = ra.i; // , expr subst
                if (i__ > 1)
                {
                    r_cnjg(&q__3, &rs);
                    q__2.r = -q__3.r;
                    q__2.i = -q__3.i; // , expr subst
                    i__1 = *ku + i__ * ab_dim1;
                    q__1.r = q__2.r * ab[i__1].r - q__2.i * ab[i__1].i;
                    q__1.i = q__2.r * ab[i__1].i + q__2.i * ab[i__1] .r; // , expr subst
                    rb.r = q__1.r;
                    rb.i = q__1.i; // , expr subst
                    i__1 = *ku + i__ * ab_dim1;
                    i__2 = *ku + i__ * ab_dim1;
                    q__1.r = rc * ab[i__2].r;
                    q__1.i = rc * ab[i__2].i; // , expr subst
                    ab[i__1].r = q__1.r;
                    ab[i__1].i = q__1.i; // , expr subst
                }
                if (wantpt)
                {
                    r_cnjg(&q__1, &rs);
                    crot_(n, &pt[i__ + pt_dim1], ldpt, &pt[*m + 1 + pt_dim1], ldpt, &rc, &q__1);
                }
                /* L110: */
            }
        }
    }
    /* Make diagonal and superdiagonal elements real, storing them in D */
    /* and E */
    i__1 = *ku + 1 + ab_dim1;
    t.r = ab[i__1].r;
    t.i = ab[i__1].i; // , expr subst
    i__1 = minmn;
    for (i__ = 1;
            i__ <= i__1;
            ++i__)
    {
        abst = c_abs(&t);
        d__[i__] = abst;
        if (abst != 0.f)
        {
            q__1.r = t.r / abst;
            q__1.i = t.i / abst; // , expr subst
            t.r = q__1.r;
            t.i = q__1.i; // , expr subst
        }
        else
        {
            t.r = 1.f;
            t.i = 0.f; // , expr subst
        }
        if (wantq)
        {
            cscal_(m, &t, &q[i__ * q_dim1 + 1], &c__1);
        }
        if (wantc)
        {
            r_cnjg(&q__1, &t);
            cscal_(ncc, &q__1, &c__[i__ + c_dim1], ldc);
        }
        if (i__ < minmn)
        {
            if (*ku == 0 && *kl == 0)
            {
                e[i__] = 0.f;
                i__2 = (i__ + 1) * ab_dim1 + 1;
                t.r = ab[i__2].r;
                t.i = ab[i__2].i; // , expr subst
            }
            else
            {
                if (*ku == 0)
                {
                    i__2 = i__ * ab_dim1 + 2;
                    r_cnjg(&q__2, &t);
                    q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i;
                    q__1.i = ab[i__2].r * q__2.i + ab[i__2].i * q__2.r; // , expr subst
                    t.r = q__1.r;
                    t.i = q__1.i; // , expr subst
                }
                else
                {
                    i__2 = *ku + (i__ + 1) * ab_dim1;
                    r_cnjg(&q__2, &t);
                    q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i;
                    q__1.i = ab[i__2].r * q__2.i + ab[i__2].i * q__2.r; // , expr subst
                    t.r = q__1.r;
                    t.i = q__1.i; // , expr subst
                }
                abst = c_abs(&t);
                e[i__] = abst;
                if (abst != 0.f)
                {
                    q__1.r = t.r / abst;
                    q__1.i = t.i / abst; // , expr subst
                    t.r = q__1.r;
                    t.i = q__1.i; // , expr subst
                }
                else
                {
                    t.r = 1.f;
                    t.i = 0.f; // , expr subst
                }
                if (wantpt)
                {
                    cscal_(n, &t, &pt[i__ + 1 + pt_dim1], ldpt);
                }
                i__2 = *ku + 1 + (i__ + 1) * ab_dim1;
                r_cnjg(&q__2, &t);
                q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i;
                q__1.i = ab[i__2].r * q__2.i + ab[i__2].i * q__2.r; // , expr subst
                t.r = q__1.r;
                t.i = q__1.i; // , expr subst
            }
        }
        /* L120: */
    }
    return 0;
    /* End of CGBBRD */
}
/* cgbbrd_ */