Inverse Matrix Implementation Problem...
zhenggen
zhenggen@public1.ptt.js.cn
Wed Jul 3 07:23:00 GMT 2002
W L A Au wrote:
>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:
>
There are two basic concepts which you should grasp before you can
continue your work.
(1) The declaration of array(one-dimensional or multi-dimensional):
" float **a ;" will not declare an array, rather it declares a
pointer. "a" is a pointer which can point to an array of float pointers.
The simplest way to declare a 3 by 3 array is : float a[3][3];
(2) header files and library files.
In a .C file, a "#include ..." statement only tells the compiler to
find ,in this header file, the definition of symbols appeared in this C
file . The compile stage will pass smoothly if you don't provide the
respective object file, which is normally put in an archived library
file together with other object files. The object file, which is created
from the relevant C file, is needed in link phase. If the archived
library file is named libmath.a, then you have to tell ld to attach this
library in the following way:
gcc test2.c -o test2 -lmath
Please notice the notation. It should be "-lmath" ,not "-llibmath.a"
In your codes, there is a line:
#include "nrutil.h"
but no library is given explicitly in the command line. Surely you will
fail.
There are one exception. When you put line like "#include <stdlib.h>"
in your c file, the relavant object file, or library will be
automatically attached to your execute file. It is called C runtime library.
I hope this will help you.
More information about the Gcc-help
mailing list