mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 02:33:59 +08:00
improved selftest for Eigen::Complex -- mainly a documentation of what does not work
This commit is contained in:
parent
288ba155f1
commit
7911df4b6e
@ -210,8 +210,20 @@ operator<< (std::basic_ostream<charT,traits>& ostr, const Complex<T>& rhs)
|
||||
template<class T> Complex<T> sqrt (const Complex<T>&x){return sqrt(ei_to_std(x));}
|
||||
template<class T> Complex<T> tan (const Complex<T>&x){return tan(ei_to_std(x));}
|
||||
template<class T> Complex<T> tanh (const Complex<T>&x){return tanh(ei_to_std(x));}
|
||||
}
|
||||
|
||||
template<typename _Real> struct NumTraits<Complex<_Real> >
|
||||
{
|
||||
typedef _Real Real;
|
||||
typedef Complex<_Real> FloatingPoint;
|
||||
enum {
|
||||
IsComplex = 1,
|
||||
HasFloatingPoint = NumTraits<Real>::HasFloatingPoint,
|
||||
ReadCost = 2,
|
||||
AddCost = 2 * NumTraits<Real>::AddCost,
|
||||
MulCost = 4 * NumTraits<Real>::MulCost + 2 * NumTraits<Real>::AddCost
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
/* vim: set filetype=cpp et sw=2 ts=2 ai: */
|
||||
|
||||
|
@ -22,13 +22,12 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
#ifdef EIGEN_TEST_FUNC
|
||||
#include "main.h"
|
||||
# include "main.h"
|
||||
#else
|
||||
#include <iostream>
|
||||
|
||||
#define CALL_SUBTEST(x) x
|
||||
#define VERIFY(x) x
|
||||
#define test_Complex main
|
||||
# include <iostream>
|
||||
# define CALL_SUBTEST(x) x
|
||||
# define VERIFY(x) x
|
||||
# define test_Complex main
|
||||
#endif
|
||||
|
||||
#include <unsupported/Eigen/Complex>
|
||||
@ -47,26 +46,32 @@ void take_std( std::complex<T> * dst, int n )
|
||||
template <typename T>
|
||||
void syntax()
|
||||
{
|
||||
vector< Complex<T> > a;
|
||||
a.resize( 9 );
|
||||
//Complex<T> a[9];
|
||||
Complex<T> b[9];
|
||||
|
||||
std::complex<T> * pa = &a[0]; // this works fine
|
||||
std::complex<T> * pb = &b[0]; // this works fine
|
||||
//VERIFY()
|
||||
// this does not compile:
|
||||
// take_std( &a[0] , a.size() );
|
||||
|
||||
// this works fine
|
||||
Matrix< Complex<T>, 9, 1> a;
|
||||
std::complex<T> * pa = &a[0];
|
||||
Complex<T> * pa2 = &a[0];
|
||||
take_std( pa,9);
|
||||
|
||||
// this does not work, but I wish it would
|
||||
// take_std(&a[0];)
|
||||
// this does
|
||||
take_std( (std::complex<T> *)&a[0],9);
|
||||
|
||||
// this does not work, but it would be really nice
|
||||
//vector< Complex<T> > a;
|
||||
// (on my gcc 4.4.1 )
|
||||
// std::vector assumes operator& returns a POD pointer
|
||||
|
||||
// this works fine
|
||||
Complex<T> b[9];
|
||||
std::complex<T> * pb = &b[0]; // this works fine
|
||||
|
||||
take_std( pb,9);
|
||||
//take_std( static_cast<std::complex<T> *>( &a[0] ) , a.size() );
|
||||
//take_std( &b[0] , 9 );
|
||||
}
|
||||
|
||||
int test_Complex()
|
||||
void test_Complex()
|
||||
{
|
||||
CALL_SUBTEST( syntax<float>() );
|
||||
//CALL_SUBTEST( syntax<double>() );
|
||||
//CALL_SUBTEST( syntax<long double>() );
|
||||
CALL_SUBTEST( syntax<double>() );
|
||||
CALL_SUBTEST( syntax<long double>() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user