3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE CLAHILB(N, NRHS, A, LDA, X, LDX, B, LDB, WORK,
14 * .. Scalar Arguments ..
15 * INTEGER T, N, NRHS, LDA, LDX, LDB, INFO
16 * .. Array Arguments ..
18 * COMPLEX A(LDA,N), X(LDX, NRHS), B(LDB, NRHS)
28 *> CLAHILB generates an N by N scaled Hilbert matrix in A along with
29 *> NRHS right-hand sides in B and solutions in X such that A*X=B.
31 *> The Hilbert matrix is scaled by M = LCM(1, 2, ..., 2*N-1) so that all
32 *> entries are integers. The right-hand sides are the first NRHS
33 *> columns of M * the identity matrix, and the solutions are the
34 *> first NRHS columns of the inverse Hilbert matrix.
36 *> The condition number of the Hilbert matrix grows exponentially with
37 *> its size, roughly as O(e ** (3.5*N)). Additionally, the inverse
38 *> Hilbert matrices beyond a relatively small dimension cannot be
39 *> generated exactly without extra precision. Precision is exhausted
40 *> when the largest entry in the inverse Hilbert matrix is greater than
41 *> 2 to the power of the number of bits in the fraction of the data type
42 *> used plus one, which is 24 for single precision.
44 *> In single, the generated solution is exact for N <= 6 and has
45 *> small componentwise error for 7 <= N <= 11.
54 *> The dimension of the matrix A.
60 *> The requested number of right-hand sides.
65 *> A is COMPLEX array, dimension (LDA, N)
66 *> The generated scaled Hilbert matrix.
72 *> The leading dimension of the array A. LDA >= N.
77 *> X is COMPLEX array, dimension (LDX, NRHS)
78 *> The generated exact solutions. Currently, the first NRHS
79 *> columns of the inverse Hilbert matrix.
85 *> The leading dimension of the array X. LDX >= N.
90 *> B is REAL array, dimension (LDB, NRHS)
91 *> The generated right-hand sides. Currently, the first NRHS
92 *> columns of LCM(1, 2, ..., 2*N-1) * the identity matrix.
98 *> The leading dimension of the array B. LDB >= N.
103 *> WORK is REAL array, dimension (N)
109 *> = 0: successful exit
110 *> = 1: N is too large; the data is still generated but may not
112 *> < 0: if INFO = -i, the i-th argument had an illegal value
117 *> PATH is CHARACTER*3
118 *> The LAPACK path name.
124 *> \author Univ. of Tennessee
125 *> \author Univ. of California Berkeley
126 *> \author Univ. of Colorado Denver
129 *> \date December 2016
131 *> \ingroup complex_lin
133 * =====================================================================
134 SUBROUTINE CLAHILB(N, NRHS, A, LDA, X, LDX, B, LDB, WORK,
137 * -- LAPACK test routine (version 3.7.0) --
138 * -- LAPACK is a software package provided by Univ. of Tennessee, --
139 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
142 * .. Scalar Arguments ..
143 INTEGER T, N, NRHS, LDA, LDX, LDB, INFO
144 * .. Array Arguments ..
146 COMPLEX A(LDA,N), X(LDX, NRHS), B(LDB, NRHS)
150 * =====================================================================
151 * .. Local Scalars ..
159 * NMAX_EXACT the largest dimension where the generated data is
161 * NMAX_APPROX the largest dimension where the generated data has
162 * a small componentwise relative error.
163 * ??? complex uses how many bits ???
164 INTEGER NMAX_EXACT, NMAX_APPROX, SIZE_D
165 PARAMETER (NMAX_EXACT = 6, NMAX_APPROX = 11, SIZE_D = 8)
167 * d's are generated from random permuation of those eight elements.
168 COMPLEX D1(8), D2(8), INVD1(8), INVD2(8)
169 DATA D1 /(-1,0),(0,1),(-1,-1),(0,-1),(1,0),(-1,1),(1,1),(1,-1)/
170 DATA D2 /(-1,0),(0,-1),(-1,1),(0,1),(1,0),(-1,-1),(1,-1),(1,1)/
172 DATA INVD1 /(-1,0),(0,-1),(-.5,.5),(0,1),(1,0),
173 $ (-.5,-.5),(.5,-.5),(.5,.5)/
174 DATA INVD2 /(-1,0),(0,1),(-.5,-.5),(0,-1),(1,0),
175 $ (-.5,.5),(.5,.5),(.5,-.5)/
177 * .. External Functions
178 EXTERNAL CLASET, LSAMEN
182 * .. Executable Statements ..
185 * Test the input arguments
188 IF (N .LT. 0 .OR. N .GT. NMAX_APPROX) THEN
190 ELSE IF (NRHS .LT. 0) THEN
192 ELSE IF (LDA .LT. N) THEN
194 ELSE IF (LDX .LT. N) THEN
196 ELSE IF (LDB .LT. N) THEN
199 IF (INFO .LT. 0) THEN
200 CALL XERBLA('CLAHILB', -INFO)
203 IF (N .GT. NMAX_EXACT) THEN
207 * Compute M = the LCM of the integers [1, 2*N-1]. The largest
208 * reasonable N is small enough that integers suffice (up to N = 11).
222 * Generate the scaled Hilbert matrix in A
223 * If we are testing SY routines, take D1_i = D2_i, else, D1_i = D2_i*
224 IF ( LSAMEN( 2, C2, 'SY' ) ) THEN
227 A(I, J) = D1(MOD(J,SIZE_D)+1) * (REAL(M) / (I + J - 1))
228 $ * D1(MOD(I,SIZE_D)+1)
234 A(I, J) = D1(MOD(J,SIZE_D)+1) * (REAL(M) / (I + J - 1))
235 $ * D2(MOD(I,SIZE_D)+1)
240 * Generate matrix B as simply the first NRHS columns of M * the
243 CALL CLASET('Full', N, NRHS, (0.0,0.0), TMP, B, LDB)
245 * Generate the true solutions in X. Because B = the first NRHS
246 * columns of M*I, the true solutions are just the first NRHS columns
247 * of the inverse Hilbert matrix.
250 WORK(J) = ( ( (WORK(J-1)/(J-1)) * (J-1 - N) ) /(J-1) )
254 * If we are testing SY routines, take D1_i = D2_i, else, D1_i = D2_i*
255 IF ( LSAMEN( 2, C2, 'SY' ) ) THEN
259 $ INVD1(MOD(J,SIZE_D)+1) *
260 $ ((WORK(I)*WORK(J)) / (I + J - 1))
261 $ * INVD1(MOD(I,SIZE_D)+1)
268 $ INVD2(MOD(J,SIZE_D)+1) *
269 $ ((WORK(I)*WORK(J)) / (I + J - 1))
270 $ * INVD1(MOD(I,SIZE_D)+1)