xref: /aosp_15_r20/external/eigen/test/is_same_dense.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li // This file is part of Eigen, a lightweight C++ template library
2*bf2c3715SXin Li // for linear algebra.
3*bf2c3715SXin Li //
4*bf2c3715SXin Li // Copyright (C) 2015 Gael Guennebaud <[email protected]>
5*bf2c3715SXin Li //
6*bf2c3715SXin Li // This Source Code Form is subject to the terms of the Mozilla
7*bf2c3715SXin Li // Public License v. 2.0. If a copy of the MPL was not distributed
8*bf2c3715SXin Li // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9*bf2c3715SXin Li 
10*bf2c3715SXin Li #include "main.h"
11*bf2c3715SXin Li 
12*bf2c3715SXin Li using internal::is_same_dense;
13*bf2c3715SXin Li 
EIGEN_DECLARE_TEST(is_same_dense)14*bf2c3715SXin Li EIGEN_DECLARE_TEST(is_same_dense)
15*bf2c3715SXin Li {
16*bf2c3715SXin Li   typedef Matrix<double,Dynamic,Dynamic,ColMajor> ColMatrixXd;
17*bf2c3715SXin Li   typedef Matrix<std::complex<double>,Dynamic,Dynamic,ColMajor> ColMatrixXcd;
18*bf2c3715SXin Li   ColMatrixXd m1(10,10);
19*bf2c3715SXin Li   ColMatrixXcd m2(10,10);
20*bf2c3715SXin Li   Ref<ColMatrixXd> ref_m1(m1);
21*bf2c3715SXin Li   Ref<ColMatrixXd,0, Stride<Dynamic,Dynamic> >  ref_m2_real(m2.real());
22*bf2c3715SXin Li   Ref<const ColMatrixXd> const_ref_m1(m1);
23*bf2c3715SXin Li 
24*bf2c3715SXin Li   VERIFY(is_same_dense(m1,m1));
25*bf2c3715SXin Li   VERIFY(is_same_dense(m1,ref_m1));
26*bf2c3715SXin Li   VERIFY(is_same_dense(const_ref_m1,m1));
27*bf2c3715SXin Li   VERIFY(is_same_dense(const_ref_m1,ref_m1));
28*bf2c3715SXin Li 
29*bf2c3715SXin Li   VERIFY(is_same_dense(m1.block(0,0,m1.rows(),m1.cols()),m1));
30*bf2c3715SXin Li   VERIFY(!is_same_dense(m1.row(0),m1.col(0)));
31*bf2c3715SXin Li 
32*bf2c3715SXin Li   Ref<const ColMatrixXd> const_ref_m1_row(m1.row(1));
33*bf2c3715SXin Li   VERIFY(!is_same_dense(m1.row(1),const_ref_m1_row));
34*bf2c3715SXin Li 
35*bf2c3715SXin Li   Ref<const ColMatrixXd> const_ref_m1_col(m1.col(1));
36*bf2c3715SXin Li   VERIFY(is_same_dense(m1.col(1),const_ref_m1_col));
37*bf2c3715SXin Li 
38*bf2c3715SXin Li 
39*bf2c3715SXin Li   VERIFY(!is_same_dense(m1, ref_m2_real));
40*bf2c3715SXin Li   VERIFY(!is_same_dense(m2, ref_m2_real));
41*bf2c3715SXin Li }
42