is_same_dense.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
  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. using internal::is_same_dense;
  11. EIGEN_DECLARE_TEST(is_same_dense)
  12. {
  13. typedef Matrix<double,Dynamic,Dynamic,ColMajor> ColMatrixXd;
  14. typedef Matrix<std::complex<double>,Dynamic,Dynamic,ColMajor> ColMatrixXcd;
  15. ColMatrixXd m1(10,10);
  16. ColMatrixXcd m2(10,10);
  17. Ref<ColMatrixXd> ref_m1(m1);
  18. Ref<ColMatrixXd,0, Stride<Dynamic,Dynamic> > ref_m2_real(m2.real());
  19. Ref<const ColMatrixXd> const_ref_m1(m1);
  20. VERIFY(is_same_dense(m1,m1));
  21. VERIFY(is_same_dense(m1,ref_m1));
  22. VERIFY(is_same_dense(const_ref_m1,m1));
  23. VERIFY(is_same_dense(const_ref_m1,ref_m1));
  24. VERIFY(is_same_dense(m1.block(0,0,m1.rows(),m1.cols()),m1));
  25. VERIFY(!is_same_dense(m1.row(0),m1.col(0)));
  26. Ref<const ColMatrixXd> const_ref_m1_row(m1.row(1));
  27. VERIFY(!is_same_dense(m1.row(1),const_ref_m1_row));
  28. Ref<const ColMatrixXd> const_ref_m1_col(m1.col(1));
  29. VERIFY(is_same_dense(m1.col(1),const_ref_m1_col));
  30. VERIFY(!is_same_dense(m1, ref_m2_real));
  31. VERIFY(!is_same_dense(m2, ref_m2_real));
  32. }