Thread overview | |||||
---|---|---|---|---|---|
|
March 18, 2003 sqrt() error | ||||
---|---|---|---|---|
| ||||
todouble() converts two ints, a numerator and a denominator, into a double and returns it. When I try to take the square root of the double, I get the errors below. As hard as it is to believe STLport will only take the square root of a float and a long double. (See _cmath.h, which is included in cmath.) When I cast the return of todouble() to long double it worked. std::cout << "Fraction x is " << x << "\tsqrt x is "<< std::sqrt(x.todouble()) << std::endl; ^ ftest6.cpp(40) : Error: ambiguous reference to symbol Had: std::_inline_sqrt(float ) and: std::_inline_sqrt(long double ) frac6WR.cpp: ftest6.cpp: --- errorlevel 1 |
March 18, 2003 Re: sqrt() error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jim Jennings | Some of math functions, and sqrt among them, are #define'd in math.h. Defines serve to promote sqrt/sin/cos an other calls to intrinsic calls. But this surely prevents normal usage of STL. When ported Blitz to DMC++, I used the code below to suppress this errors: ----------- #include <math.h> #undef sin #undef cos #undef fabs #undef sqrt inline double cos (double x) { return _inline_cos(x);} inline double sin (double x) { return _inline_sin(x);} inline double fabs (double x) { return _inline_fabs(x);} inline double sqrt (double x) { return _inline_sqrt(x);} ------------ You should insert it before you make calls to std::sqrt. Or even simpler solution, write sqrt instead of std::sqrt. Nic Tiger. "Jim Jennings" <jwjenn@mindspring.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:b57s60$16lp$1@digitaldaemon.com... > todouble() converts two ints, a numerator and a denominator, into a double and returns it. When I try to take the square root of the double, I get the > errors below. As hard as it is to believe STLport will only take the square > root of a float and a long double. (See _cmath.h, which is included in > cmath.) When I cast the return of todouble() to long double it worked. > > std::cout << "Fraction x is " << x << "\tsqrt x is "<< > std::sqrt(x.todouble()) << std::endl; > ^ > ftest6.cpp(40) : Error: ambiguous reference to symbol > Had: std::_inline_sqrt(float ) > and: std::_inline_sqrt(long double ) > frac6WR.cpp: > ftest6.cpp: > --- errorlevel 1 > > > > > > > > > > > > > > > |
March 19, 2003 Re: sqrt() error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nic Tiger | Thank you, Nic. This works. I have filed this away, and will use it in the future. JIm "Nic Tiger" <nictiger@progtech.ru> wrote in message news:b588j0$1gpb$1@digitaldaemon.com... > Some of math functions, and sqrt among them, are #define'd in math.h. Defines serve to promote sqrt/sin/cos an other calls to intrinsic calls. But > this surely prevents normal usage of STL. > > When ported Blitz to DMC++, I used the code below to suppress this errors: > ----------- > #include <math.h> > #undef sin > #undef cos > #undef fabs > #undef sqrt > > inline double cos (double x) { return _inline_cos(x);} > inline double sin (double x) { return _inline_sin(x);} > inline double fabs (double x) { return _inline_fabs(x);} > inline double sqrt (double x) { return _inline_sqrt(x);} > ------------ > You should insert it before you make calls to std::sqrt. > > Or even simpler solution, write sqrt instead of std::sqrt. > > Nic Tiger. > |
Copyright © 1999-2021 by the D Language Foundation