Immo's solutions

Numerical recipes
xlinbcg.c

GMT
PostScript problem
setpagedevice
 
IML++ / SparseLib++
Missing include file for
diagonal preconditioner
 
awk
Numerical recipes

The routine "xlinbcg.c" in the Example Book [C] of "Numerical Recipes in C" (Second Edition) uses a different matrix as input than described.

The sparse matrix matrix represented by the arrays ija and sa with 

unsigned long ija[NSIZE+1] ={
 0,22,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,
 59,60,2,1,3,2,4,3,5,4,6,5,7,6,8,7,9,8,10,9,11,10,12,11,13,12,
 14,13,15,14,16,15,17,16,18,17,19,18,20,19};

double sa[NSIZE+1] ={
 0.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,
 3.0,3.0,3.0,3.0,0.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,
 2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,
 -2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0,2.0,-2.0};

does not equal the 20 x 20 matrix 

(as described in the text) but the following matrix:

If you use the matrix with the values of 3.0 in the diagonal together with vector b=(3.0,1.0,1.0,...,1.0.-1.0) you will obtain the same solution as with the routine "xlinbcg.c".
 
 
 
GMT

In case you can't print a PostScript file that was created with Generic Mapping Tools the reason is probably the following:

The PostScript interpreter of your printer driver does not understand the command "setpagedevice".
 

Immo's solution:

Open the PostScript file in a text editor, search for the expression "setpagedevice" and comment each line that contains this expression with a "%" or delete this line.
 

Alternatively you can avoid the problem by settting the PAPER_MEDIA value in the GMT script to EPS
gmtset PAPER_MEDIA = a4+

or by editing your .gmtdefaults file correspondingly.
 
IML++

The Iterative Methods Library v. 1.2a (IML++ ) requires the formulation of a preconditioner to make use of the conjugate and biconjugate gradient algorithms. These preconditioners can be created using the sparse matrix library SparseLib++.

The examples described in the reference guide to IML++ v.1.2  requiere the inclusion of a file called "mv_blas1_double.h".

Neither SparseLib++ nor IML++ contains this file.
 

Immo's solution:

Don't use IML++. 

awk

If you want to reformat a block of data like

0.1 0.2 0.3
0.4 0.5 0.6
0.7 0.8 0.9
...

into a column of data you can use awk.
Assuming that the block of data is saved in a file called "data" you can use

cat data | awk '{i=1;while(i<NF+1){print $i"" ; ++i}}'

and you will obtain:

0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
...


Go home !