Nektar++
Functions
Nektar::StandardMatrixUnitTests Namespace Reference

Functions

 BOOST_AUTO_TEST_CASE (TestIterators)
 
 BOOST_AUTO_TEST_CASE (TestWrappedCopyConstructor)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

Nektar::StandardMatrixUnitTests::BOOST_AUTO_TEST_CASE ( TestIterators  )

Definition at line 49 of file TestStandardMatrix.cpp.

50{
51 double buf1[] = {1, 4, 2, 5, 3, 6};
52
53 NekMatrix<double> m1(2, 3, buf1);
54 const NekMatrix<double> &m2 = m1;
55
56 NekMatrix<double>::iterator m1_iter = m1.begin();
57 NekMatrix<double>::const_iterator m2_iter = m2.begin();
58
59 BOOST_CHECK_EQUAL(1, *m1_iter);
60 BOOST_CHECK_EQUAL(1, *m2_iter);
61 BOOST_CHECK_EQUAL(1, *m1_iter++);
62 BOOST_CHECK_EQUAL(1, *m2_iter++);
63 BOOST_CHECK_EQUAL(4, *m1_iter++);
64 BOOST_CHECK_EQUAL(4, *m2_iter++);
65 BOOST_CHECK_EQUAL(2, *m1_iter++);
66 BOOST_CHECK_EQUAL(2, *m2_iter++);
67 BOOST_CHECK_EQUAL(5, *m1_iter++);
68 BOOST_CHECK_EQUAL(5, *m2_iter++);
69 BOOST_CHECK_EQUAL(3, *m1_iter++);
70 BOOST_CHECK_EQUAL(3, *m2_iter++);
71 BOOST_CHECK_EQUAL(6, *m1_iter++);
72 BOOST_CHECK_EQUAL(6, *m2_iter++);
73 BOOST_CHECK(m1_iter == m1.end());
74 BOOST_CHECK(m2_iter == m2.end());
75
76 m1.Transpose();
77 m1_iter = m1.begin();
78 m2_iter = m2.begin();
79
80 BOOST_CHECK_EQUAL(1, *m1_iter);
81 BOOST_CHECK_EQUAL(1, *m2_iter);
82 BOOST_CHECK_EQUAL(2, *(++m1_iter));
83 BOOST_CHECK_EQUAL(2, *(++m2_iter));
84 BOOST_CHECK_EQUAL(3, *(++m1_iter));
85 BOOST_CHECK_EQUAL(3, *(++m2_iter));
86 BOOST_CHECK_EQUAL(4, *(++m1_iter));
87 BOOST_CHECK_EQUAL(4, *(++m2_iter));
88 BOOST_CHECK_EQUAL(5, *(++m1_iter));
89 BOOST_CHECK_EQUAL(5, *(++m2_iter));
90 BOOST_CHECK_EQUAL(6, *(++m1_iter));
91 BOOST_CHECK_EQUAL(6, *(++m2_iter));
92 BOOST_CHECK(m1_iter != m1.end());
93 BOOST_CHECK(m2_iter != m2.end());
94 ++m1_iter;
95 ++m2_iter;
96 BOOST_CHECK(m1_iter == m1.end());
97 BOOST_CHECK(m2_iter == m2.end());
98}

◆ BOOST_AUTO_TEST_CASE() [2/2]

Nektar::StandardMatrixUnitTests::BOOST_AUTO_TEST_CASE ( TestWrappedCopyConstructor  )

Definition at line 100 of file TestStandardMatrix.cpp.

101{
102 double buf1[] = {1, 4, 2, 5, 3, 6};
103
104 NekMatrix<double> m1(2, 3, buf1);
106
107 BOOST_CHECK_EQUAL(1.0, m1(0, 0));
108 BOOST_CHECK_EQUAL(1.0, m2(0, 0));
109
110 m1(0, 0) = -4.5;
111
112 BOOST_CHECK_EQUAL(-4.5, m1(0, 0));
113 BOOST_CHECK_EQUAL(-4.5, m2(0, 0));
114
115 BOOST_CHECK_EQUAL(4.0, m1(1, 0));
116 BOOST_CHECK_EQUAL(4.0, m2(1, 0));
117
118 m2(1, 0) = 6.7;
119
120 BOOST_CHECK_EQUAL(6.7, m1(1, 0));
121 BOOST_CHECK_EQUAL(6.7, m2(1, 0));
122}