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.

41 lines
1.5 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. typedef typename MatrixType::Scalar Scalar;
  14. #ifdef NDEBUG
  15. const bool is_debug = false;
  16. #else
  17. const bool is_debug = true;
  18. #endif
  19. // Make really sure that we are in debug mode! We don't want any type of
  20. // inlining for these tests to pass.
  21. VERIFY(is_debug);
  22. // The only intention of these tests is to ensure that this code does
  23. // not trigger any asserts or segmentation faults... more to come.
  24. VERIFY_IS_APPROX( (m.transpose() * m).diagonal().sum(), (m.transpose() * m).diagonal().sum() );
  25. VERIFY_IS_APPROX( (m.transpose() * m).diagonal().array().abs().sum(), (m.transpose() * m).diagonal().array().abs().sum() );
  26. VERIFY_IS_APPROX( (m.transpose() * m).array().abs().sum(), (m.transpose() * m).array().abs().sum() );
  27. }
  28. void test_nesting_ops()
  29. {
  30. CALL_SUBTEST_1(run_nesting_ops(MatrixXf::Random(25,25)));
  31. CALL_SUBTEST_2(run_nesting_ops(MatrixXd::Random(25,25)));
  32. CALL_SUBTEST_3(run_nesting_ops(Matrix4f::Random()));
  33. CALL_SUBTEST_4(run_nesting_ops(Matrix4d::Random()));
  34. }