1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#include "main.h"
11
12template <typename MatrixType> void run_nesting_ops(const MatrixType& _m)
13{
14  typename MatrixType::Nested m(_m);
15
16  // Make really sure that we are in debug mode!
17  VERIFY_RAISES_ASSERT(eigen_assert(false));
18
19  // The only intention of these tests is to ensure that this code does
20  // not trigger any asserts or segmentation faults... more to come.
21  VERIFY_IS_APPROX( (m.transpose() * m).diagonal().sum(), (m.transpose() * m).diagonal().sum() );
22  VERIFY_IS_APPROX( (m.transpose() * m).diagonal().array().abs().sum(), (m.transpose() * m).diagonal().array().abs().sum() );
23
24  VERIFY_IS_APPROX( (m.transpose() * m).array().abs().sum(), (m.transpose() * m).array().abs().sum() );
25}
26
27void test_nesting_ops()
28{
29  CALL_SUBTEST_1(run_nesting_ops(MatrixXf::Random(25,25)));
30  CALL_SUBTEST_2(run_nesting_ops(MatrixXd::Random(25,25)));
31  CALL_SUBTEST_3(run_nesting_ops(Matrix4f::Random()));
32  CALL_SUBTEST_4(run_nesting_ops(Matrix4d::Random()));
33}
34