hello, dear all
i'm try to find determinant . there is error with ' pow':

sum = sum + b[0][p]*pow(-1,p)*determinant(c,m-1);
 return sum;

after run, the argument was appear as follows:
1>c:\documents and settings\user\my documents\visual studio 2008\projects\deter4\deter4\deter4.cpp(78) : error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)' .
how to correct it?

Your first argument to pow( ) must be one of the floating point types (float, double, long double). If your code is such that you really want/need 'c' to be an integer type, then do a typecast in the function call, such as ans = pow( (double)c, m-1 ); (yes, I'm using old style typecasting for simplicity's sake!)

Never use a very expensive pow() function in this context. You want to change subexpression sign for odd p only. Make it explicitly, it's much more faster code:

temp = b[0][p]*determinant(c,m-1);
if ((p&1) != 0)
    sum -= temp;
else
    sum += temp;
return sum;

or, may be

temp = b[0][p]*determinant(c,m-1);
return (p$1)?sum - temp:sum+temp; // if sum is local var

thanks it works!

if you want to get (pow) value for complex number you should include complex.h.

you should include complex.h.

You mean #include <complex> not #include <complex[B].h[/B]>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.