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.

50 lines
1.5 KiB

  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@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. #define EIGEN_NO_STATIC_ASSERT
  10. #include "product.h"
  11. // regression test for bug 447
  12. void product1x1()
  13. {
  14. Matrix<float,1,3> matAstatic;
  15. Matrix<float,3,1> matBstatic;
  16. matAstatic.setRandom();
  17. matBstatic.setRandom();
  18. VERIFY_IS_APPROX( (matAstatic * matBstatic).coeff(0,0),
  19. matAstatic.cwiseProduct(matBstatic.transpose()).sum() );
  20. MatrixXf matAdynamic(1,3);
  21. MatrixXf matBdynamic(3,1);
  22. matAdynamic.setRandom();
  23. matBdynamic.setRandom();
  24. VERIFY_IS_APPROX( (matAdynamic * matBdynamic).coeff(0,0),
  25. matAdynamic.cwiseProduct(matBdynamic.transpose()).sum() );
  26. }
  27. void test_product_small()
  28. {
  29. for(int i = 0; i < g_repeat; i++) {
  30. CALL_SUBTEST_1( product(Matrix<float, 3, 2>()) );
  31. CALL_SUBTEST_2( product(Matrix<int, 3, 5>()) );
  32. CALL_SUBTEST_3( product(Matrix3d()) );
  33. CALL_SUBTEST_4( product(Matrix4d()) );
  34. CALL_SUBTEST_5( product(Matrix4f()) );
  35. CALL_SUBTEST_6( product1x1() );
  36. }
  37. #ifdef EIGEN_TEST_PART_6
  38. {
  39. // test compilation of (outer_product) * vector
  40. Vector3f v = Vector3f::Random();
  41. VERIFY_IS_APPROX( (v * v.transpose()) * v, (v * v.transpose()).eval() * v);
  42. }
  43. #endif
  44. }