Nektar++
Typedefs | Functions
Nektar::BandedMatrixStoragePolicyUnitTests Namespace Reference

Typedefs

typedef BandedMatrixFuncs Policy
 

Functions

 BOOST_AUTO_TEST_CASE (TestCalculateStorageSizeAndCalculateNumberOfRows)
 
 BOOST_AUTO_TEST_CASE (TestDiagonalOnlyCalculateIndex)
 
 BOOST_AUTO_TEST_CASE (TestSubDiagonalsOnlyCalculateIndex)
 
 BOOST_AUTO_TEST_CASE (TestSuperDiagonalsOnlyCalculateIndex)
 
 BOOST_AUTO_TEST_CASE (TestSupAndSuperDiagonalsCalculateIndex)
 
 BOOST_AUTO_TEST_CASE (TestSetValue)
 

Typedef Documentation

◆ Policy

Definition at line 45 of file TestBandedMatrixStoragePolicy.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

Nektar::BandedMatrixStoragePolicyUnitTests::BOOST_AUTO_TEST_CASE ( TestCalculateStorageSizeAndCalculateNumberOfRows  )

Definition at line 47 of file TestBandedMatrixStoragePolicy.cpp.

48{
50 BOOST_CHECK_EQUAL(16u, Policy::GetRequiredStorageSize(4, 4, 2, 1));
51 BOOST_CHECK_EQUAL(4u, Policy::CalculateNumberOfRows(4, 2, 1));
52 BOOST_CHECK_EQUAL(4u, Policy::CalculateNumberOfRows(3, 2, 1));
53}
void RedirectCerrIfNeeded()
Definition: util.cpp:41

References Nektar::BandedMatrixFuncs::CalculateNumberOfRows(), Nektar::BandedMatrixFuncs::GetRequiredStorageSize(), and Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [2/6]

Nektar::BandedMatrixStoragePolicyUnitTests::BOOST_AUTO_TEST_CASE ( TestDiagonalOnlyCalculateIndex  )

Definition at line 55 of file TestBandedMatrixStoragePolicy.cpp.

56{
58
59 BOOST_CHECK_EQUAL(0, Policy::CalculateIndex(3, 3, 0, 0, 0, 0));
60 BOOST_CHECK_EQUAL(1, Policy::CalculateIndex(3, 3, 1, 1, 0, 0));
61 BOOST_CHECK_EQUAL(2, Policy::CalculateIndex(3, 3, 2, 2, 0, 0));
62 BOOST_CHECK_EQUAL(0, Policy::CalculateIndex(1, 1, 0, 0, 0, 0));
63
64 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
65 Policy::CalculateIndex(3, 3, 0, 1, 0, 0));
66 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
67 Policy::CalculateIndex(3, 3, 0, 2, 0, 0));
68 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
69 Policy::CalculateIndex(3, 3, 1, 0, 0, 0));
70 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
71 Policy::CalculateIndex(3, 3, 1, 2, 0, 0));
72 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
73 Policy::CalculateIndex(3, 3, 2, 0, 0, 0));
74 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
75 Policy::CalculateIndex(3, 3, 2, 1, 0, 0));
76}

References Nektar::BandedMatrixFuncs::CalculateIndex(), and Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [3/6]

Nektar::BandedMatrixStoragePolicyUnitTests::BOOST_AUTO_TEST_CASE ( TestSetValue  )

Definition at line 146 of file TestBandedMatrixStoragePolicy.cpp.

147{
149
150 // [ 1 2 3 0 ]
151 // [ 4 5 6 7 ]
152 // [ 0 8 9 10 ]
153 // [ 0 0 11 12 ]
154 NekDouble buf[] = {0, 0, 1, 4, 0, 2, 5, 8, 3, 6, 9, 11, 7, 10, 12, 0};
155 NekMatrix<NekDouble> m(4, 4, buf, eBANDED, 1, 2);
156
157 BOOST_CHECK_EQUAL(1, m(0, 0));
158 m.SetValue(0, 0, 19);
159 BOOST_CHECK_EQUAL(19, m(0, 0));
160 BOOST_CHECK_EQUAL(2, m(0, 1));
161 m.SetValue(0, 1, 20);
162 BOOST_CHECK_EQUAL(20, m(0, 1));
163 BOOST_CHECK_EQUAL(3, m(0, 2));
164 m.SetValue(0, 2, 21);
165 BOOST_CHECK_EQUAL(21, m(0, 2));
166 BOOST_CHECK_EQUAL(0, m(0, 3));
167 BOOST_CHECK_THROW(m.SetValue(0, 3, 21), ErrorUtil::NekError);
168
169 BOOST_CHECK_EQUAL(4, m(1, 0));
170 m.SetValue(1, 0, 22);
171 BOOST_CHECK_EQUAL(22, m(1, 0));
172 BOOST_CHECK_EQUAL(5, m(1, 1));
173 m.SetValue(1, 1, 23);
174 BOOST_CHECK_EQUAL(23, m(1, 1));
175 BOOST_CHECK_EQUAL(6, m(1, 2));
176 m.SetValue(1, 2, 24);
177 BOOST_CHECK_EQUAL(24, m(1, 2));
178 BOOST_CHECK_EQUAL(7, m(1, 3));
179 m.SetValue(1, 3, 25);
180 BOOST_CHECK_EQUAL(25, m(1, 3));
181
182 BOOST_CHECK_EQUAL(0, m(2, 0));
183 BOOST_CHECK_THROW(m.SetValue(2, 0, 21), ErrorUtil::NekError);
184 BOOST_CHECK_EQUAL(8, m(2, 1));
185 m.SetValue(2, 1, 26);
186 BOOST_CHECK_EQUAL(26, m(2, 1));
187 BOOST_CHECK_EQUAL(9, m(2, 2));
188 m.SetValue(2, 2, 27);
189 BOOST_CHECK_EQUAL(27, m(2, 2));
190 BOOST_CHECK_EQUAL(10, m(2, 3));
191 m.SetValue(2, 3, 28);
192 BOOST_CHECK_EQUAL(28, m(2, 3));
193
194 BOOST_CHECK_EQUAL(0, m(3, 0));
195 BOOST_CHECK_THROW(m.SetValue(3, 0, 21), ErrorUtil::NekError);
196 BOOST_CHECK_EQUAL(0, m(3, 1));
197 BOOST_CHECK_THROW(m.SetValue(3, 1, 21), ErrorUtil::NekError);
198 BOOST_CHECK_EQUAL(11, m(3, 2));
199 m.SetValue(3, 2, 29);
200 BOOST_CHECK_EQUAL(29, m(3, 2));
201 BOOST_CHECK_EQUAL(12, m(3, 3));
202 m.SetValue(3, 3, 30);
203 BOOST_CHECK_EQUAL(30, m(3, 3));
204}
double NekDouble

References Nektar::eBANDED, and Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [4/6]

Nektar::BandedMatrixStoragePolicyUnitTests::BOOST_AUTO_TEST_CASE ( TestSubDiagonalsOnlyCalculateIndex  )

Definition at line 78 of file TestBandedMatrixStoragePolicy.cpp.

79{
81
82 BOOST_CHECK_EQUAL(0, Policy::CalculateIndex(3, 3, 0, 0, 1, 0));
83 BOOST_CHECK_EQUAL(2, Policy::CalculateIndex(3, 3, 1, 1, 1, 0));
84 BOOST_CHECK_EQUAL(4, Policy::CalculateIndex(3, 3, 2, 2, 1, 0));
85 BOOST_CHECK_EQUAL(1, Policy::CalculateIndex(3, 3, 1, 0, 1, 0));
86 BOOST_CHECK_EQUAL(3, Policy::CalculateIndex(3, 3, 2, 1, 1, 0));
87
88 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
89 Policy::CalculateIndex(3, 3, 0, 1, 1, 0));
90 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
91 Policy::CalculateIndex(3, 3, 0, 2, 1, 0));
92 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
93 Policy::CalculateIndex(3, 3, 2, 0, 1, 0));
94 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
95 Policy::CalculateIndex(3, 3, 1, 2, 1, 0));
96}

References Nektar::BandedMatrixFuncs::CalculateIndex(), and Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [5/6]

Nektar::BandedMatrixStoragePolicyUnitTests::BOOST_AUTO_TEST_CASE ( TestSupAndSuperDiagonalsCalculateIndex  )

Definition at line 117 of file TestBandedMatrixStoragePolicy.cpp.

118{
120
121 BOOST_CHECK_EQUAL(2, Policy::CalculateIndex(4, 4, 0, 0, 1, 2));
122 BOOST_CHECK_EQUAL(5, Policy::CalculateIndex(4, 4, 0, 1, 1, 2));
123 BOOST_CHECK_EQUAL(8, Policy::CalculateIndex(4, 4, 0, 2, 1, 2));
124 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
125 Policy::CalculateIndex(4, 4, 0, 3, 1, 2));
126
127 BOOST_CHECK_EQUAL(3, Policy::CalculateIndex(4, 4, 1, 0, 1, 2));
128 BOOST_CHECK_EQUAL(6, Policy::CalculateIndex(4, 4, 1, 1, 1, 2));
129 BOOST_CHECK_EQUAL(9, Policy::CalculateIndex(4, 4, 1, 2, 1, 2));
130 BOOST_CHECK_EQUAL(12, Policy::CalculateIndex(4, 4, 1, 3, 1, 2));
131
132 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
133 Policy::CalculateIndex(4, 4, 2, 0, 1, 2));
134 BOOST_CHECK_EQUAL(7, Policy::CalculateIndex(4, 4, 2, 1, 1, 2));
135 BOOST_CHECK_EQUAL(10, Policy::CalculateIndex(4, 4, 2, 2, 1, 2));
136 BOOST_CHECK_EQUAL(13, Policy::CalculateIndex(4, 4, 2, 3, 1, 2));
137
138 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
139 Policy::CalculateIndex(4, 4, 3, 0, 1, 2));
140 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
141 Policy::CalculateIndex(4, 4, 3, 1, 1, 2));
142 BOOST_CHECK_EQUAL(11, Policy::CalculateIndex(4, 4, 3, 2, 1, 2));
143 BOOST_CHECK_EQUAL(14, Policy::CalculateIndex(4, 4, 3, 3, 1, 2));
144}

References Nektar::BandedMatrixFuncs::CalculateIndex(), and Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [6/6]

Nektar::BandedMatrixStoragePolicyUnitTests::BOOST_AUTO_TEST_CASE ( TestSuperDiagonalsOnlyCalculateIndex  )

Definition at line 98 of file TestBandedMatrixStoragePolicy.cpp.

99{
101
102 BOOST_CHECK_EQUAL(2, Policy::CalculateIndex(3, 3, 0, 0, 0, 2));
103 BOOST_CHECK_EQUAL(5, Policy::CalculateIndex(3, 3, 1, 1, 0, 2));
104 BOOST_CHECK_EQUAL(8, Policy::CalculateIndex(3, 3, 2, 2, 0, 2));
105 BOOST_CHECK_EQUAL(4, Policy::CalculateIndex(3, 3, 0, 1, 0, 2));
106 BOOST_CHECK_EQUAL(7, Policy::CalculateIndex(3, 3, 1, 2, 0, 2));
107 BOOST_CHECK_EQUAL(6, Policy::CalculateIndex(3, 3, 0, 2, 0, 2));
108
109 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
110 Policy::CalculateIndex(3, 3, 1, 0, 0, 2));
111 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
112 Policy::CalculateIndex(3, 3, 2, 0, 0, 2));
113 BOOST_CHECK_EQUAL(std::numeric_limits<unsigned int>::max(),
114 Policy::CalculateIndex(3, 3, 2, 1, 0, 2));
115}

References Nektar::BandedMatrixFuncs::CalculateIndex(), and Nektar::UnitTests::RedirectCerrIfNeeded().