Inverse Matrix Implementation Problem...

W L A Au eem1wa@eim.surrey.ac.uk
Tue Jul 2 16:27:00 GMT 2002


Dear Sir/Madam,

Please help me. I've encounter some problems when I try to implement the
inverse matrix function by using the Gauss-Jordan Elimination routine,
which is provided by the Numerical Recipes in C, Chapter 2.1

http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf.html

What exactly I want to do is:

First, put in the values of a 2D matrix, A

                3 5 0
for example, A= 6 1 4
                1 1 2

Then, add an equal dimension 2D identity matrix to A

   3 5 0 1 0 0
=> 6 1 4 0 1 0
   1 1 2 0 0 1
   
After that, do row elementary operation (eg. addition, multiplication, swap
row...) in order to form an identity matrix on the left

   1 0 0 1/23  5/23  -10/23
=> 0 1 0 4/23  -3/23 6/23
   0 0 1 -5/46 -1/23 27/46

When the left hand side become an identity matrix, the right hand side will
become the inverse of A. So, I use the gaussj() function
provided by the book to achieve this. However, when I use the gcc compiler
command:

gcc test2.c -o test2

I've got the following error message:

Undefined			first referenced
 symbol  			    in file
free_ivector                        /var/tmp/cc4v8fRq.o
ivector                             /var/tmp/cc4v8fRq.o
nrerror                             /var/tmp/cc4v8fRq.o
ld: fatal: Symbol referencing errors. No output written to test2
collect2: ld returned 1 exit status

It seems I can not include the nrutil.h header file. But I've put it in the
same subdirectory with test2.c already. How this can be fix?

Also, the 2D matrix, a. Is already declared as "float **a" in the routine.
I've try to use it by substitude values in, like

a[0][0] = 3;   a[1][0] = 5;   a[2][0] = 0;
a[0][1] = 6;   a[1][1] = 1;   a[2][1] = 4;
a[0][2] = 1;   a[1][2] = 1;   a[2][2] = 2;

in order to find the inverse matrix of a. But error massage come out as
well. I guess this is not right at all. How can I make it right?

Finally, I'm not sure did I use the gaussj() function correctly. Did I miss
something in my implementation?

I would like to thank you in advance for helping me. Thank a lot!

Yours Sincerely,
Alderick

PS. The test2.c and nrutil.h files are attached with this email.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test2.c
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20020702/4383a0df/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nrutil.h
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20020702/4383a0df/attachment.h>


More information about the Gcc-help mailing list