CNLMath : Utilities : generate_test_band (complex)
generate_test_band (complex)
Generates test matrices of class Ec(n, c). Returns in band or band symmetric format.
Synopsis
#include <imsl.h>
f_complex *imsl_c_generate_test_band (int n, int c, ..., 0)
The function imsl_z_generate_test_band is the double precision analogue.
Required Arguments
int n (Input)
Number of rows in the matrix.
int c (Input)
Parameter used to alter structure, also the number of upper/lower codiagonals
Return Value
A pointer to a vector of type f_complex. To release this space, use imsl_free. If no test was generated, then NULL is returned.
Synopsis with Optional Arguments
#include <imsl.h>
void *imsl_c_generate_test_band (int n, int c,
IMSL_SYMMETRIC_STORAGE,
0)
Optional Arguments
IMSL_SYMMETRIC_STORAGE,
Return matrix stored in band symmetric format.
Description
We use the same nomenclature as Østerby and Zlatev (1982). Test matrices of class E(n, c), to which we will generally refer to as E-matrices, are symmetric, positive definite matrices of order n with (6.0, 0.0) in the diagonal, (-1.0, 1.0) in the superdiagonal and (-1.0, -1.0) subdiagonal. In addition there are two bands at a distance c from the diagonal with (-1.0, 1.0) in the upper codiagonal and (-1.0, − 1.0) in the lower codiagonal. More precisely:
ai,i = 6
0 i < n
ai,i+1 =  −1  − i
0 i < n  −1
ai+1,i =  −1  − i
0 i < n  − 1
ai,i+c =  −1 + i
0 i < n  − c
ai+c,i =  −1 + i
0 i < n  − c
for any n 3 and 2 c n  − 1.
E-matrices are similar to those obtained from the five-point formula in the discretization of elliptic partial differential equations.
By default, imsl_c_generate_test_band returns an E-matrix in band storage mode. Option IMSL_SYMMETRIC_STORAGE returns a matrix in band symmetric storage mode.
Example
This example generates the following matrix and prints the result:
 
#include <imsl.h>
 
int main()
{
int i;
int n = 5;
int c = 3;
f_complex *a;
 
a = imsl_c_generate_test_band (n, c, 0);
 
imsl_c_write_matrix ("E(5,3) in band storage", 2*c + 1, n,
a, 0);
}
Output
 
E(5,3) in band storage
1 2 3
1 ( 0, 0) ( 0, 0) ( 0, 0)
2 ( 0, 0) ( 0, 0) ( 0, 0)
3 ( 0, 0) ( -1, 1) ( -1, 1)
4 ( 6, 0) ( 6, 0) ( 6, 0)
5 ( -1, -1) ( -1, -1) ( -1, -1)
6 ( 0, 0) ( 0, 0) ( 0, 0)
7 ( -1, -1) ( -1, -1) ( 0, 0)
 
4 5
1 ( -1, 1) ( -1, 1)
2 ( 0, 0) ( 0, 0)
3 ( -1, 1) ( -1, 1)
4 ( 6, 0) ( 6, 0)
5 ( -1, -1) ( 0, 0)
6 ( 0, 0) ( 0, 0)
7 ( 0, 0) ( 0, 0)