You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.3 KiB

  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. #include "main.h"
  10. template <typename MatrixType> void run_nesting_ops(const MatrixType& _m)
  11. {
  12. typename MatrixType::Nested m(_m);
  13. // Make really sure that we are in debug mode!
  14. VERIFY_RAISES_ASSERT(eigen_assert(false));
  15. // The only intention of these tests is to ensure that this code does
  16. // not trigger any asserts or segmentation faults... more to come.
  17. VERIFY_IS_APPROX( (m.transpose() * m).diagonal().sum(), (m.transpose() * m).diagonal().sum() );
  18. VERIFY_IS_APPROX( (m.transpose() * m).diagonal().array().abs().sum(), (m.transpose() * m).diagonal().array().abs().sum() );
  19. VERIFY_IS_APPROX( (m.transpose() * m).array().abs().sum(), (m.transpose() * m).array().abs().sum() );
  20. }
  21. void test_nesting_ops()
  22. {
  23. CALL_SUBTEST_1(run_nesting_ops(MatrixXf::Random(25,25)));
  24. CALL_SUBTEST_2(run_nesting_ops(MatrixXd::Random(25,25)));
  25. CALL_SUBTEST_3(run_nesting_ops(Matrix4f::Random()));
  26. CALL_SUBTEST_4(run_nesting_ops(Matrix4d::Random()));
  27. }