Hi,

I've made a program from numerical recipes. Looks like I'm not allowed

to distribute the source code from numerical recipes but it shouldn't

even be necessary to do that.

My problem is that I'm not very experienced with pointers, pointers to

pointers and the like and I got 4 compiler warnings + I don't completely

understand how to build this "compact matrix" (see later).

I'm also not completely sure if I understand the text correct... So far

my program looks like this:

#include <math.h>

#include "nrutil.h"

/* definitions */

#define number_of_rows 7

#define TINY 1.0e-20

#define SWAP(a,b) {dum=(a);(a)=(b);(b)=dum;}

/* prototypes */

void banmul(float **a, unsigned long n, int left, int right, float x[],

float b[]);

void bandec(float **a, unsigned long n, int left, int right, float **al,

unsigned long indx[], float *d);

void banbks(float **a, unsigned long n, int left, int right, float **al,

unsigned long indx[], float b[]);

/* Start of main program */

int main(void)

{

/* declaration */

double x[number_of_rows], b[number_of_rows]; // remember that we're

solving "b = A * x"

/* initialisation */

double a[][number_of_rows] = // number_of_cols = number_of_rows

{

{3.,1.,0.,0.,0.,0.,0.},

{4.,1.,5.,0.,0.,0.,0.},

{9.,2.,6.,5.,0.,0.,0.},

{0.,3.,5.,8.,9.,0.,0.},

{0.,0.,7.,9.,3.,2.,0.},

{0.,0.,0.,3.,8.,4.,6.},

{0.,0.,0.,0.,2.,4.,4.}

};

banmul(a, number_of_rows, 2, 1, x, b);

printf("\nFinishing program now.\n\n");

}

If there's anything you need to know you can read it here:

http://www.library.cornell.edu/nr/bookcpdf/c2-4.pdf (start from the

chapter with "Band diagonal system, p.52".

You can see my 2D-matrix is the same... The text talks about transposing

the matrix to a more compact form... I must admit I need some help

because I didn't understand the text :-(

My compiler warnings (don't know what to do):

----

warning C4047: 'function' : 'float **' differs in levels of indirection

from 'double [7][7]'

warning C4024: 'banmul' : different types for formal and actual parameter 1

warning C4133: 'function' : incompatible types - from 'double [7]' to

'float *'

warning C4133: 'function' : incompatible types - from 'double [7]' to

'float *'

----

The problem is the line: "banmul(a, ....)";

So, generally, I don't really understand what I'm doing :-(

The x-array (vector) is not defined. If somebody could show me an

example of how to solve this matrix system, I would be very happy (you

just make x whatever you like: x=[2,5,2,1,6,2,1] or whatever...

AFAIK the text from numerical recipes and my code should be enough for

you to understand my code and I hope somebody can give me some hints

that can get me closer to a solution.

Thanks in advance for any (hopefully good) inputs...

Best regards / Med venlig hilsen

Martin Jørgensen

--

---------------------------------------------------------------------------

Home of Martin Jørgensen - http://www.martinjoergensen.dk