Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / dlasdt.c
1 #include "clapack.h"
2
3 /* Subroutine */ int dlasdt_(integer *n, integer *lvl, integer *nd, integer *
4         inode, integer *ndiml, integer *ndimr, integer *msub)
5 {
6     /* System generated locals */
7     integer i__1, i__2;
8
9     /* Builtin functions */
10     double log(doublereal);
11
12     /* Local variables */
13     integer i__, il, ir, maxn;
14     doublereal temp;
15     integer nlvl, llst, ncrnt;
16
17
18 /*  -- LAPACK auxiliary routine (version 3.1) -- */
19 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
20 /*     November 2006 */
21
22 /*     .. Scalar Arguments .. */
23 /*     .. */
24 /*     .. Array Arguments .. */
25 /*     .. */
26
27 /*  Purpose */
28 /*  ======= */
29
30 /*  DLASDT creates a tree of subproblems for bidiagonal divide and */
31 /*  conquer. */
32
33 /*  Arguments */
34 /*  ========= */
35
36 /*   N      (input) INTEGER */
37 /*          On entry, the number of diagonal elements of the */
38 /*          bidiagonal matrix. */
39
40 /*   LVL    (output) INTEGER */
41 /*          On exit, the number of levels on the computation tree. */
42
43 /*   ND     (output) INTEGER */
44 /*          On exit, the number of nodes on the tree. */
45
46 /*   INODE  (output) INTEGER array, dimension ( N ) */
47 /*          On exit, centers of subproblems. */
48
49 /*   NDIML  (output) INTEGER array, dimension ( N ) */
50 /*          On exit, row dimensions of left children. */
51
52 /*   NDIMR  (output) INTEGER array, dimension ( N ) */
53 /*          On exit, row dimensions of right children. */
54
55 /*   MSUB   (input) INTEGER. */
56 /*          On entry, the maximum row dimension each subproblem at the */
57 /*          bottom of the tree can be of. */
58
59 /*  Further Details */
60 /*  =============== */
61
62 /*  Based on contributions by */
63 /*     Ming Gu and Huan Ren, Computer Science Division, University of */
64 /*     California at Berkeley, USA */
65
66 /*  ===================================================================== */
67
68 /*     .. Parameters .. */
69 /*     .. */
70 /*     .. Local Scalars .. */
71 /*     .. */
72 /*     .. Intrinsic Functions .. */
73 /*     .. */
74 /*     .. Executable Statements .. */
75
76 /*     Find the number of levels on the tree. */
77
78     /* Parameter adjustments */
79     --ndimr;
80     --ndiml;
81     --inode;
82
83     /* Function Body */
84     maxn = max(1,*n);
85     temp = log((doublereal) maxn / (doublereal) (*msub + 1)) / log(2.);
86     *lvl = (integer) temp + 1;
87
88     i__ = *n / 2;
89     inode[1] = i__ + 1;
90     ndiml[1] = i__;
91     ndimr[1] = *n - i__ - 1;
92     il = 0;
93     ir = 1;
94     llst = 1;
95     i__1 = *lvl - 1;
96     for (nlvl = 1; nlvl <= i__1; ++nlvl) {
97
98 /*        Constructing the tree at (NLVL+1)-st level. The number of */
99 /*        nodes created on this level is LLST * 2. */
100
101         i__2 = llst - 1;
102         for (i__ = 0; i__ <= i__2; ++i__) {
103             il += 2;
104             ir += 2;
105             ncrnt = llst + i__;
106             ndiml[il] = ndiml[ncrnt] / 2;
107             ndimr[il] = ndiml[ncrnt] - ndiml[il] - 1;
108             inode[il] = inode[ncrnt] - ndimr[il] - 1;
109             ndiml[ir] = ndimr[ncrnt] / 2;
110             ndimr[ir] = ndimr[ncrnt] - ndiml[ir] - 1;
111             inode[ir] = inode[ncrnt] + ndiml[ir] + 1;
112 /* L10: */
113         }
114         llst <<= 1;
115 /* L20: */
116     }
117     *nd = (llst << 1) - 1;
118
119     return 0;
120
121 /*     End of DLASDT */
122
123 } /* dlasdt_ */