Expandable
2007-05-14, 14:59:29
Hallo,
ich würde gerne komplexe Zahlen (std::complex) mit rationalen Zahlen (boost::rational) als Real- und Imaginärteil verwenden. Jedoch spuckt der folgende simple Code bei mir einen Compiler-Fehler aus (VS05Pro):
#include <complex>
#include <boost/rational.hpp>
int main()
{
std::complex<boost::rational<int> > a(boost::rational<int>(4,6), boost::rational<int>(5,7));
std::complex<boost::rational<int> > b(boost::rational<int>(4,6), boost::rational<int>(5,7));
std::complex<boost::rational<int> > c = a / b;
}
Die Fehlermeldung lautet:
1>c:\program files\microsoft visual studio 8\vc\include\complex(74) : error C2440: 'type cast' : cannot convert from 'boost::rational<IntType>' to 'double'
1> with
1> [
1> IntType=int
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files\microsoft visual studio 8\vc\include\complex(73) : while compiling class template member function 'bool std::_Ctraits<_Ty>::_Isnan(_Ty)'
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\complex(481) : see reference to class template instantiation 'std::_Ctraits<_Ty>' being compiled
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\complex(1028) : see reference to function template instantiation 'void std::_Complex_base<_Ty,_Valbase>::_Div<boost::rational<IntType>>(const std::complex<_Ty> &)' being compiled
1> with
1> [
1> _Ty=boost::rational<int>,
1> _Valbase=std::_Complex_value<boost::rational<int>>,
1> IntType=int
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\complex(1027) : while compiling class template member function 'std::complex<_Ty> &std::complex<_Ty>::operator /=(const std::complex<_Ty> &)'
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
1> e:\test\test.cpp(560) : see reference to class template instantiation 'std::complex<_Ty>' being compiled
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
Die entsprechende Funktion will scheinbar wirklich Rational in einen double konvertieren:
static bool __CLRCALL_OR_CDECL _Isnan(_Ty _Left)
{ // test for NaN
double _Tmp = (double)_Left;
return (::_Dtest(&_Tmp) == _NANCODE);
}
Kann mir da jemand weiterhelfen? Bei Google hab ich leider nix gefunden...
Danke im voraus...
ich würde gerne komplexe Zahlen (std::complex) mit rationalen Zahlen (boost::rational) als Real- und Imaginärteil verwenden. Jedoch spuckt der folgende simple Code bei mir einen Compiler-Fehler aus (VS05Pro):
#include <complex>
#include <boost/rational.hpp>
int main()
{
std::complex<boost::rational<int> > a(boost::rational<int>(4,6), boost::rational<int>(5,7));
std::complex<boost::rational<int> > b(boost::rational<int>(4,6), boost::rational<int>(5,7));
std::complex<boost::rational<int> > c = a / b;
}
Die Fehlermeldung lautet:
1>c:\program files\microsoft visual studio 8\vc\include\complex(74) : error C2440: 'type cast' : cannot convert from 'boost::rational<IntType>' to 'double'
1> with
1> [
1> IntType=int
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files\microsoft visual studio 8\vc\include\complex(73) : while compiling class template member function 'bool std::_Ctraits<_Ty>::_Isnan(_Ty)'
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\complex(481) : see reference to class template instantiation 'std::_Ctraits<_Ty>' being compiled
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\complex(1028) : see reference to function template instantiation 'void std::_Complex_base<_Ty,_Valbase>::_Div<boost::rational<IntType>>(const std::complex<_Ty> &)' being compiled
1> with
1> [
1> _Ty=boost::rational<int>,
1> _Valbase=std::_Complex_value<boost::rational<int>>,
1> IntType=int
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\complex(1027) : while compiling class template member function 'std::complex<_Ty> &std::complex<_Ty>::operator /=(const std::complex<_Ty> &)'
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
1> e:\test\test.cpp(560) : see reference to class template instantiation 'std::complex<_Ty>' being compiled
1> with
1> [
1> _Ty=boost::rational<int>
1> ]
Die entsprechende Funktion will scheinbar wirklich Rational in einen double konvertieren:
static bool __CLRCALL_OR_CDECL _Isnan(_Ty _Left)
{ // test for NaN
double _Tmp = (double)_Left;
return (::_Dtest(&_Tmp) == _NANCODE);
}
Kann mir da jemand weiterhelfen? Bei Google hab ich leider nix gefunden...
Danke im voraus...