improved selftest for Eigen::Complex -- mainly a documentation of what does not work

This commit is contained in:
Mark Borgerding
2009-10-28 23:22:10 -04:00
parent 288ba155f1
commit 7911df4b6e
2 changed files with 40 additions and 23 deletions

View File

@@ -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>() );
}