| 23 | enum my_sizes { M = 12, N = 7}; |
| 24 | |
| 25 | template<typename MatrixType> void ctor_init1(const MatrixType& m) |
| 26 | { |
| 27 | // Check logic in PlainObjectBase::_init1 |
| 28 | Index rows = m.rows(); |
| 29 | Index cols = m.cols(); |
| 30 | |
| 31 | MatrixType m0 = MatrixType::Random(rows,cols); |
| 32 | |
| 33 | VERIFY_EVALUATION_COUNT( MatrixType m1(m0), 1); |
| 34 | VERIFY_EVALUATION_COUNT( MatrixType m2(m0+m0), 1); |
| 35 | VERIFY_EVALUATION_COUNT( MatrixType m2(m0.block(0,0,rows,cols)) , 1); |
| 36 | |
| 37 | Wrapper<MatrixType> wrapper(m0); |
| 38 | VERIFY_EVALUATION_COUNT( MatrixType m3(wrapper) , 1); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | EIGEN_DECLARE_TEST(constructor) |
| 43 | { |
| 44 | for(int i = 0; i < g_repeat; i++) { |
| 45 | CALL_SUBTEST_1( ctor_init1(Matrix<float, 1, 1>()) ); |
| 46 | CALL_SUBTEST_1( ctor_init1(Matrix4d()) ); |
| 47 | CALL_SUBTEST_1( ctor_init1(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); |
| 48 | CALL_SUBTEST_1( ctor_init1(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); |
| 49 | } |
| 50 | { |
| 51 | Matrix<Index,1,1> a(123); |
| 52 | VERIFY_IS_EQUAL(a[0], 123); |
| 53 | } |
| 54 | { |
| 55 | Matrix<Index,1,1> a(123.0); |
| 56 | VERIFY_IS_EQUAL(a[0], 123); |
| 57 | } |
| 58 | { |
| 59 | Matrix<float,1,1> a(123); |
| 60 | VERIFY_IS_EQUAL(a[0], 123.f); |
| 61 | } |
| 62 | { |
| 63 | Array<Index,1,1> a(123); |
| 64 | VERIFY_IS_EQUAL(a[0], 123); |
| 65 | } |
| 66 | { |
| 67 | Array<Index,1,1> a(123.0); |
| 68 | VERIFY_IS_EQUAL(a[0], 123); |
| 69 | } |
| 70 | { |
| 71 | Array<float,1,1> a(123); |
| 72 | VERIFY_IS_EQUAL(a[0], 123.f); |
| 73 | } |
| 74 | { |
| 75 | Array<Index,3,3> a(123); |
| 76 | VERIFY_IS_EQUAL(a(4), 123); |
| 77 | } |
| 78 | { |
| 79 | Array<Index,3,3> a(123.0); |
| 80 | VERIFY_IS_EQUAL(a(4), 123); |
| 81 | } |
| 82 | { |