3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE SLAHILB( N, NRHS, A, LDA, X, LDX, B, LDB, WORK, INFO)
13 * .. Scalar Arguments ..
14 * INTEGER N, NRHS, LDA, LDX, LDB, INFO
15 * .. Array Arguments ..
16 * REAL A(LDA, N), X(LDX, NRHS), B(LDB, NRHS), WORK(N)
25 *> SLAHILB generates an N by N scaled Hilbert matrix in A along with
26 *> NRHS right-hand sides in B and solutions in X such that A*X=B.
28 *> The Hilbert matrix is scaled by M = LCM(1, 2, ..., 2*N-1) so that all
29 *> entries are integers. The right-hand sides are the first NRHS
30 *> columns of M * the identity matrix, and the solutions are the
31 *> first NRHS columns of the inverse Hilbert matrix.
33 *> The condition number of the Hilbert matrix grows exponentially with
34 *> its size, roughly as O(e ** (3.5*N)). Additionally, the inverse
35 *> Hilbert matrices beyond a relatively small dimension cannot be
36 *> generated exactly without extra precision. Precision is exhausted
37 *> when the largest entry in the inverse Hilbert matrix is greater than
38 *> 2 to the power of the number of bits in the fraction of the data type
39 *> used plus one, which is 24 for single precision.
41 *> In single, the generated solution is exact for N <= 6 and has
42 *> small componentwise error for 7 <= N <= 11.
51 *> The dimension of the matrix A.
57 *> The requested number of right-hand sides.
62 *> A is REAL array, dimension (LDA, N)
63 *> The generated scaled Hilbert matrix.
69 *> The leading dimension of the array A. LDA >= N.
74 *> X is REAL array, dimension (LDX, NRHS)
75 *> The generated exact solutions. Currently, the first NRHS
76 *> columns of the inverse Hilbert matrix.
82 *> The leading dimension of the array X. LDX >= N.
87 *> B is REAL array, dimension (LDB, NRHS)
88 *> The generated right-hand sides. Currently, the first NRHS
89 *> columns of LCM(1, 2, ..., 2*N-1) * the identity matrix.
95 *> The leading dimension of the array B. LDB >= N.
100 *> WORK is REAL array, dimension (N)
106 *> = 0: successful exit
107 *> = 1: N is too large; the data is still generated but may not
109 *> < 0: if INFO = -i, the i-th argument had an illegal value
115 *> \author Univ. of Tennessee
116 *> \author Univ. of California Berkeley
117 *> \author Univ. of Colorado Denver
120 *> \date November 2015
122 *> \ingroup real_matgen
124 * =====================================================================
125 SUBROUTINE SLAHILB( N, NRHS, A, LDA, X, LDX, B, LDB, WORK, INFO)
127 * -- LAPACK test routine (version 3.6.0) --
128 * -- LAPACK is a software package provided by Univ. of Tennessee, --
129 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
132 * .. Scalar Arguments ..
133 INTEGER N, NRHS, LDA, LDX, LDB, INFO
134 * .. Array Arguments ..
135 REAL A(LDA, N), X(LDX, NRHS), B(LDB, NRHS), WORK(N)
138 * =====================================================================
139 * .. Local Scalars ..
145 * NMAX_EXACT the largest dimension where the generated data is
147 * NMAX_APPROX the largest dimension where the generated data has
148 * a small componentwise relative error.
149 INTEGER NMAX_EXACT, NMAX_APPROX
150 PARAMETER (NMAX_EXACT = 6, NMAX_APPROX = 11)
153 * .. External Functions
157 * .. Executable Statements ..
159 * Test the input arguments
162 IF (N .LT. 0 .OR. N .GT. NMAX_APPROX) THEN
164 ELSE IF (NRHS .LT. 0) THEN
166 ELSE IF (LDA .LT. N) THEN
168 ELSE IF (LDX .LT. N) THEN
170 ELSE IF (LDB .LT. N) THEN
173 IF (INFO .LT. 0) THEN
174 CALL XERBLA('SLAHILB', -INFO)
177 IF (N .GT. NMAX_EXACT) THEN
181 * Compute M = the LCM of the integers [1, 2*N-1]. The largest
182 * reasonable N is small enough that integers suffice (up to N = 11).
196 * Generate the scaled Hilbert matrix in A
199 A(I, J) = REAL(M) / (I + J - 1)
203 * Generate matrix B as simply the first NRHS columns of M * the
205 CALL SLASET('Full', N, NRHS, 0.0, REAL(M), B, LDB)
207 * Generate the true solutions in X. Because B = the first NRHS
208 * columns of M*I, the true solutions are just the first NRHS columns
209 * of the inverse Hilbert matrix.
212 WORK(J) = ( ( (WORK(J-1)/(J-1)) * (J-1 - N) ) /(J-1) )
218 X(I, J) = (WORK(I)*WORK(J)) / (I + J - 1)