Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #define EIGEN2_SUPPORT
00026
00027 #include "main.h"
00028
00029 template<typename MatrixType> void eigen2support(const MatrixType& m)
00030 {
00031 typedef typename MatrixType::Index Index;
00032 typedef typename MatrixType::Scalar Scalar;
00033
00034 Index rows = m.rows();
00035 Index cols = m.cols();
00036
00037 MatrixType m1 = MatrixType::Random(rows, cols),
00038 m2 = MatrixType::Random(rows, cols),
00039 m3(rows, cols);
00040
00041 Scalar s1 = internal::random<Scalar>(),
00042 s2 = internal::random<Scalar>();
00043
00044
00045 VERIFY_IS_APPROX(m1.cwise() + s1, s1 + m1.cwise());
00046 VERIFY_IS_APPROX(m1.cwise() + s1, MatrixType::Constant(rows,cols,s1) + m1);
00047 VERIFY_IS_APPROX((m1*Scalar(2)).cwise() - s2, (m1+m1) - MatrixType::Constant(rows,cols,s2) );
00048 m3 = m1;
00049 m3.cwise() += s2;
00050 VERIFY_IS_APPROX(m3, m1.cwise() + s2);
00051 m3 = m1;
00052 m3.cwise() -= s1;
00053 VERIFY_IS_APPROX(m3, m1.cwise() - s1);
00054
00055 VERIFY_IS_EQUAL((m1.corner(TopLeft,1,1)), (m1.block(0,0,1,1)));
00056 VERIFY_IS_EQUAL((m1.template corner<1,1>(TopLeft)), (m1.template block<1,1>(0,0)));
00057 VERIFY_IS_EQUAL((m1.col(0).start(1)), (m1.col(0).segment(0,1)));
00058 VERIFY_IS_EQUAL((m1.col(0).template start<1>()), (m1.col(0).segment(0,1)));
00059 VERIFY_IS_EQUAL((m1.col(0).end(1)), (m1.col(0).segment(rows-1,1)));
00060 VERIFY_IS_EQUAL((m1.col(0).template end<1>()), (m1.col(0).segment(rows-1,1)));
00061
00062 using namespace internal;
00063 VERIFY_IS_EQUAL(ei_cos(s1), cos(s1));
00064 VERIFY_IS_EQUAL(ei_real(s1), real(s1));
00065 VERIFY_IS_EQUAL(ei_abs2(s1), abs2(s1));
00066
00067 m1.minor(0,0);
00068 }
00069
00070 void test_eigen2support()
00071 {
00072 for(int i = 0; i < g_repeat; i++) {
00073 CALL_SUBTEST_1( eigen2support(Matrix<double,1,1>()) );
00074 CALL_SUBTEST_2( eigen2support(MatrixXd(1,1)) );
00075 CALL_SUBTEST_4( eigen2support(Matrix3f()) );
00076 CALL_SUBTEST_5( eigen2support(Matrix4d()) );
00077 CALL_SUBTEST_2( eigen2support(MatrixXf(200,200)) );
00078 CALL_SUBTEST_6( eigen2support(MatrixXcd(100,100)) );
00079 }
00080 }