Hi, I am doing a program that does all types of stuff with complex numbers. I think I have the code written correctly but keep getting an Undefined symbol error. It tells me sqrt and arctan and gives the file complex.o . I have #include <math.h> in my complex.c file and am using a makefile with the LIB of -lm. And everywhere I look, it says to do these things but they are already done. What could be wrong? I posted the code for the functions that use sqrt and arctan and maybe my syntax is just wrong.
Code:
#include <math.h>
.
.
.
double MagCmplx(Cmplx z)
{
/* Write this function */
double m;
m = sqrt(((z->x)*(z->x)) + ((z->y)*(z->y)));
return m;
}
double AngleCmplx(Cmplx z)
{
/* Write this function */
double theta;
if((z->y)==0 && (z->x)>0)
theta = 0;
else if((z->y)==0 && (z->x)<0)
theta = PI * (-1);
else
theta = arctan((z->x),(z->y));
return theta;
}
Please help!!! Thanks so much!
--Jacob