35 SmallVector<2> vec0{0., 1.}, vec1{2., 3.}, vec2{4., 5.}, vec3{6., 7.};
41 logger.assert_always(destroy.getNumberOfRows() == 3,
"Rows in a matrix");
42 logger.assert_always(destroy.getNCols() == 3,
"Columns in a matrix");
43 logger.assert_always(destroy.size() == 9,
"Size of a matrix");
44 for(std::size_t
i = 0;
i < destroy.size(); ++
i)
46 logger.assert_always(std::abs(destroy[
i] - 1.) < 1e-12,
"Entry of a matrix");
48 for(std::size_t
i = 0;
i < destroy.getNumberOfRows(); ++
i)
50 for(std::size_t j = 0; j < destroy.getNCols(); ++j)
52 logger.assert_always(std::abs(destroy(
i, j) - 1.) < 1e-12,
"Entry of a matrix");
56 logger.assert_always(moved.getNumberOfRows() == 3,
"Rows in a matrix");
57 logger.assert_always(moved.getNCols() == 3,
"Columns in a matrix");
58 logger.assert_always(moved.size() == 9,
"Size of a matrix");
59 for(std::size_t
i = 0;
i < moved.size(); ++
i)
61 logger.assert_always(std::abs(moved[
i] - 1.) < 1e-12,
"Entry of a matrix");
63 for(std::size_t
i = 0;
i < moved.getNumberOfRows(); ++
i)
65 for(std::size_t j = 0; j < moved.getNCols(); ++j)
67 logger.assert_always(std::abs(moved(
i, j) - 1.) < 1e-12,
"Entry of a matrix");
72 logger.assert_always(A0.
size() == 9,
"Size of a matrix");
75 logger.assert_always(A22.
size() == 4,
"Size of a matrix");
78 logger.assert_always(A23.
size() == 6,
"Size of a matrix");
81 logger.assert_always(A32.
size() == 6,
"Size of a matrix");
82 logger.assert_always(count0.getNumberOfRows() == 2,
"Rows in a matrix");
83 logger.assert_always(count0.getNCols() == 2,
"Columns in a matrix");
84 logger.assert_always(count0.size() == 4,
"Size of a matrix");
85 for(std::size_t
i = 0;
i < count0.size(); ++
i)
87 logger.assert_always(std::abs(count0[
i] -
i) < 1e-12,
"Entry of a matrix");
89 logger.assert_always(std::abs(count0(0, 0) - 0.) < 1e-12,
"Entry of a matrix");
90 logger.assert_always(std::abs(count0(1, 0) - 1.) < 1e-12,
"Entry of a matrix");
91 logger.assert_always(std::abs(count0(0, 1) - 2.) < 1e-12,
"Entry of a matrix");
92 logger.assert_always(std::abs(count0(1, 1) - 3.) < 1e-12,
"Entry of a matrix");
93 logger.assert_always(count1.getNumberOfRows() == 2,
"Rows in a matrix");
94 logger.assert_always(count1.getNCols() == 2,
"Columns in a matrix");
95 logger.assert_always(count1.size() == 4,
"Size of a matrix");
96 for(std::size_t
i = 0;
i < count1.size(); ++
i)
98 logger.assert_always(std::abs(count1[
i] - 4. -
i) < 1e-12,
"Entry of a matrix");
100 logger.assert_always(copy.getNumberOfRows() == 2,
"Rows in a matrix");
101 logger.assert_always(copy.getNCols() == 2,
"Columns in a matrix");
102 logger.assert_always(copy.size() == 4,
"Size of a matrix");
103 for(std::size_t
i = 0;
i < copy.size(); ++
i)
105 logger.assert_always(std::abs(copy[
i] -
i) < 1e-12,
"Entry of a matrix");
121 logger.assert_always(std::abs((count0*count1)(0, 0) - 10.) < 1e-12,
"multiply");
122 logger.assert_always(std::abs((count0*count1)(1, 0) - 19.) < 1e-12,
"multiply");
123 logger.assert_always(std::abs((count0*count1)(0, 1) - 14.) < 1e-12,
"multiply");
124 logger.assert_always(std::abs((count0*count1)(1, 1) - 27.) < 1e-12,
"multiply");
125 logger.assert_always(std::abs((count1*count0)(0, 0) - 6.) < 1e-12,
"multiply");
126 logger.assert_always(std::abs((count1*count0)(1, 0) - 7.) < 1e-12,
"multiply");
127 logger.assert_always(std::abs((count1*count0)(0, 1) - 26.) < 1e-12,
"multiply");
128 logger.assert_always(std::abs((count1*count0)(1, 1) - 31.) < 1e-12,
"multiply");
129 logger.assert_always(std::abs((count0*A23)(0, 0) - .2) < 1e-12,
"multiply");
130 logger.assert_always(std::abs((count0*A23)(1, 0) - .3) < 1e-12,
"multiply");
131 logger.assert_always(std::abs((count0*A23)(0, 1) - .6) < 1e-12,
"multiply");
132 logger.assert_always(std::abs((count0*A23)(1, 1) - 1.1) < 1e-12,
"multiply");
133 logger.assert_always(std::abs((count0*A23)(0, 2) - 1.) < 1e-12,
"multiply");
134 logger.assert_always(std::abs((count0*A23)(1, 2) - 1.9) < 1e-12,
"multiply");
135 logger.assert_always(std::abs((A32*count0)(0, 0) - .3) < 1e-12,
"multiply");
136 logger.assert_always(std::abs((A32*count0)(1, 0) - .4) < 1e-12,
"multiply");
137 logger.assert_always(std::abs((A32*count0)(2, 0) - .5) < 1e-12,
"multiply");
138 logger.assert_always(std::abs((A32*count0)(0, 1) - .9) < 1e-12,
"multiply");
139 logger.assert_always(std::abs((A32*count0)(1, 1) - 1.4) < 1e-12,
"multiply");
140 logger.assert_always(std::abs((A32*count0)(2, 1) - 1.9) < 1e-12,
"multiply");
141 logger.assert_always(std::abs((A32*A23)(0, 0) - .03) < 1e-12,
"multiply");
142 logger.assert_always(std::abs((A32*A23)(1, 0) - .04) < 1e-12,
"multiply");
143 logger.assert_always(std::abs((A32*A23)(2, 0) - .05) < 1e-12,
"multiply");
144 logger.assert_always(std::abs((A32*A23)(0, 1) - .09) < 1e-12,
"multiply");
145 logger.assert_always(std::abs((A32*A23)(1, 1) - .14) < 1e-12,
"multiply");
146 logger.assert_always(std::abs((A32*A23)(2, 1) - .19) < 1e-12,
"multiply");
147 logger.assert_always(std::abs((A32*A23)(0, 2) - .15) < 1e-12,
"multiply");
148 logger.assert_always(std::abs((A32*A23)(1, 2) - .24) < 1e-12,
"multiply");
149 logger.assert_always(std::abs((A32*A23)(2, 2) - .33) < 1e-12,
"multiply");
150 logger.assert_always(std::abs((A23*A32)(0, 0) - .1) < 1e-12,
"multiply");
151 logger.assert_always(std::abs((A23*A32)(1, 0) - .13) < 1e-12,
"multiply");
152 logger.assert_always(std::abs((A23*A32)(0, 1) - .28) < 1e-12,
"multiply");
153 logger.assert_always(std::abs((A23*A32)(1, 1) - .40) < 1e-12,
"multiply");
154 logger.assert_always(std::abs((vec1*count0)*vec1 - 45) < 1e-12,
"multiply");
155 logger.assert_always(std::abs(vec1*(count0*vec1) - 45) < 1e-12,
"multiply");
157 logger.assert_always(std::abs(size3*(A32*vec0) - 5) < 1e-12,
"multiply");
158 logger.assert_always(std::abs((size3*A32)*vec0 - 5) < 1e-12,
"multiply");
159 logger.assert_always(std::abs((2*count0*2)(0, 0) - 0.) < 1e-12,
"multiply");
160 logger.assert_always(std::abs((2*count0*2)(1, 0) - 4.) < 1e-12,
"multiply");
161 logger.assert_always(std::abs((2*count0*2)(0, 1) - 8.) < 1e-12,
"multiply");
162 logger.assert_always(std::abs((2*count0*2)(1, 1) - 12.) < 1e-12,
"multiply");
163 logger.assert_always(std::abs((count0/2.)(0, 0) - 0.) < 1e-12,
"divide");
164 logger.assert_always(std::abs((count0/2.)(1, 0) - .5) < 1e-12,
"divide");
165 logger.assert_always(std::abs((count0/2.)(0, 1) - 1.) < 1e-12,
"divide");
166 logger.assert_always(std::abs((count0/2.)(1, 1) - 1.5) < 1e-12,
"divide");
167 logger.assert_always(std::abs((count0+count1)(0, 0) - 4.) < 1e-12,
"add");
168 logger.assert_always(std::abs((count0+count1)(1, 0) - 6.) < 1e-12,
"add");
169 logger.assert_always(std::abs((count0+count1)(0, 1) - 8.) < 1e-12,
"add");
170 logger.assert_always(std::abs((count0+count1)(1, 1) - 10.) < 1e-12,
"add");
171 logger.assert_always(std::abs((count1+count0)(0, 0) - 4.) < 1e-12,
"add");
172 logger.assert_always(std::abs((count1+count0)(1, 0) - 6.) < 1e-12,
"add");
173 logger.assert_always(std::abs((count1+count0)(0, 1) - 8.) < 1e-12,
"add");
174 logger.assert_always(std::abs((count1+count0)(1, 1) - 10.) < 1e-12,
"add");
175 logger.assert_always(std::abs((count0-count1)(0, 0) + 4.) < 1e-12,
"subtract");
176 logger.assert_always(std::abs((count0-count1)(1, 0) + 4.) < 1e-12,
"subtract");
177 logger.assert_always(std::abs((count0-count1)(0, 1) + 4.) < 1e-12,
"subtract");
178 logger.assert_always(std::abs((count0-count1)(1, 1) + 4.) < 1e-12,
"subtract");
179 logger.assert_always(std::abs((count1-count0)(0, 0) - 4.) < 1e-12,
"subtract");
180 logger.assert_always(std::abs((count1-count0)(1, 0) - 4.) < 1e-12,
"subtract");
181 logger.assert_always(std::abs((count1-count0)(0, 1) - 4.) < 1e-12,
"subtract");
182 logger.assert_always(std::abs((count1-count0)(1, 1) - 4.) < 1e-12,
"subtract");
187 logger.assert_always(extra.
getNCols() == 2,
"Columns in a matrix");
188 logger.assert_always(extra.
size() == 4,
"Size of a matrix");
189 for(std::size_t
i = 0;
i < extra.
size(); ++
i)
191 logger.assert_always(std::abs(extra[
i] -
i) < 1e-12,
"Entry of a matrix");
194 logger.assert_always(copy.getNumberOfRows() == 2,
"Rows in a matrix");
195 logger.assert_always(copy.getNCols() == 2,
"Columns in a matrix");
196 logger.assert_always(copy.size() == 4,
"Size of a matrix");
197 for(std::size_t
i = 0;
i < copy.size(); ++
i)
199 logger.assert_always(std::abs(copy[
i] -
i - 4.) < 1e-12,
"Entry of a matrix");
202 logger.assert_always(count0.getNumberOfRows() == 2,
"Rows in a matrix");
203 logger.assert_always(count0.getNCols() == 2,
"Columns in a matrix");
204 logger.assert_always(count0.size() == 4,
"Size of a matrix");
205 logger.assert_always(std::abs((count0)(0, 0) - 10.) < 1e-12,
"multiply");
206 logger.assert_always(std::abs((count0)(1, 0) - 19.) < 1e-12,
"multiply");
207 logger.assert_always(std::abs((count0)(0, 1) - 14.) < 1e-12,
"multiply");
208 logger.assert_always(std::abs((count0)(1, 1) - 27.) < 1e-12,
"multiply");
210 logger.assert_always(count0.getNumberOfRows() == 2,
"Rows in a matrix");
211 logger.assert_always(count0.getNCols() == 2,
"Columns in a matrix");
212 logger.assert_always(count0.size() == 4,
"Size of a matrix");
213 logger.assert_always(std::abs((count0)(0, 0) - 40.) < 1e-12,
"multiply");
214 logger.assert_always(std::abs((count0)(1, 0) - 76.) < 1e-12,
"multiply");
215 logger.assert_always(std::abs((count0)(0, 1) - 56.) < 1e-12,
"multiply");
216 logger.assert_always(std::abs((count0)(1, 1) - 108.) < 1e-12,
"multiply");
218 logger.assert_always(count0.getNumberOfRows() == 2,
"Rows in a matrix");
219 logger.assert_always(count0.getNCols() == 2,
"Columns in a matrix");
220 logger.assert_always(count0.size() == 4,
"Size of a matrix");
221 logger.assert_always(std::abs((count0)(0, 0) - 20.) < 1e-12,
"divide");
222 logger.assert_always(std::abs((count0)(1, 0) - 38.) < 1e-12,
"divide");
223 logger.assert_always(std::abs((count0)(0, 1) - 28.) < 1e-12,
"divide");
224 logger.assert_always(std::abs((count0)(1, 1) - 54.) < 1e-12,
"divide");
226 logger.assert_always(copy.getNumberOfRows() == 2,
"Rows in a matrix");
227 logger.assert_always(copy.getNCols() == 2,
"Columns in a matrix");
228 logger.assert_always(copy.size() == 4,
"Size of a matrix");
229 logger.assert_always(std::abs((copy)(0, 0) - 4.) < 1e-12,
"add");
230 logger.assert_always(std::abs((copy)(1, 0) - 6.) < 1e-12,
"add");
231 logger.assert_always(std::abs((copy)(0, 1) - 8.) < 1e-12,
"add");
232 logger.assert_always(std::abs((copy)(1, 1) - 10.) < 1e-12,
"add");
235 logger.assert_always(extra.
getNCols() == 2,
"Columns in a matrix");
236 logger.assert_always(extra.
size() == 4,
"Size of a matrix");
237 logger.assert_always(std::abs((extra)(0, 0) + 20.) < 1e-12,
"subtract");
238 logger.assert_always(std::abs((extra)(1, 0) + 37.) < 1e-12,
"subtract");
239 logger.assert_always(std::abs((extra)(0, 1) + 26.) < 1e-12,
"subtract");
240 logger.assert_always(std::abs((extra)(1, 1) + 51.) < 1e-12,
"subtract");
241 extra.
axpy(3., copy);
243 logger.assert_always(extra.
getNCols() == 2,
"Columns in a matrix");
244 logger.assert_always(extra.
size() == 4,
"Size of a matrix");
245 logger.assert_always(std::abs((extra)(0, 0) + 8.) < 1e-12,
"ax+y");
246 logger.assert_always(std::abs((extra)(1, 0) + 19.) < 1e-12,
"ax+y");
247 logger.assert_always(std::abs((extra)(0, 1) + 2.) < 1e-12,
"ax+y");
248 logger.assert_always(std::abs((extra)(1, 1) + 21.) < 1e-12,
"ax+y");
250 SmallVector<3> vec3D0{{0., 1., 2.}}, vec3D1{{3., 4., 5.}}, vec3D2{{0., -1., 2.}};
251 SmallVector<4> vec4D0{{0., 1., 2., 3.}}, vec4D1{{4., 5., 6., 7.}}, vec4D2{{0., -1., 2., -3.}}, vec4D3{{0., -1., -2., 3.}};
254 logger.assert_always(std::abs(((
SmallMatrix<3, 2>({vec3D0, vec3D1}).getColumn(0)) - vec3D0)[0]) < 1e-12,
"getColumn");
255 logger.assert_always(std::abs(((
SmallMatrix<3, 2>({vec3D0, vec3D1}).getColumn(0)) - vec3D0)[1]) < 1e-12,
"getColumn");
256 logger.assert_always(std::abs(((
SmallMatrix<3, 2>({vec3D0, vec3D1}).getColumn(0)) - vec3D0)[2]) < 1e-12,
"getColumn");
258 logger.assert_always(std::abs(((
SmallMatrix<3, 2>({vec3D0, vec3D1}).getColumn(1)) - vec3D1)[0]) < 1e-12,
"getColumn");
259 logger.assert_always(std::abs(((
SmallMatrix<3, 2>({vec3D0, vec3D1}).getColumn(1)) - vec3D1)[1]) < 1e-12,
"getColumn");
260 logger.assert_always(std::abs(((
SmallMatrix<3, 2>({vec3D0, vec3D1}).getColumn(1)) - vec3D1)[2]) < 1e-12,
"getColumn");
275 logger.assert_always(std::abs((vec2 - count0.inverse() * duplicate)[0]) < 1e-12,
"inverse and solve");
276 logger.assert_always(std::abs((vec2 - count0.inverse() * duplicate)[1]) < 1e-12,
"inverse and solve");
277 logger.assert_always(std::abs((count0 - count0.inverse().inverse())[0]) < 1e-12,
"inverse");
278 logger.assert_always(std::abs((count0 - count0.inverse().inverse())[1]) < 1e-12,
"inverse");
279 logger.assert_always(std::abs((count0 - count0.inverse().inverse())[2]) < 1e-12,
"inverse");
280 logger.assert_always(std::abs((count0 - count0.inverse().inverse())[3]) < 1e-12,
"inverse");
281 logger.assert_always(std::abs((count0 - count0.transpose().transpose())[0]) < 1e-12,
"transpose");
282 logger.assert_always(std::abs((count0 - count0.transpose().transpose())[1]) < 1e-12,
"transpose");
283 logger.assert_always(std::abs((count0 - count0.transpose().transpose())[2]) < 1e-12,
"transpose");
284 logger.assert_always(std::abs((count0 - count0.transpose().transpose())[3]) < 1e-12,
"transpose");
285 logger.assert_always(std::abs(A23(0, 0) - A23.transpose()(0, 0)) < 1e-12,
"transpose");
286 logger.assert_always(std::abs(A23(1, 0) - A23.transpose()(0, 1)) < 1e-12,
"transpose");
287 logger.assert_always(std::abs(A23(0, 1) - A23.transpose()(1, 0)) < 1e-12,
"transpose");
288 logger.assert_always(std::abs(A23(1, 1) - A23.transpose()(1, 1)) < 1e-12,
"transpose");
289 logger.assert_always(std::abs(A23(0, 2) - A23.transpose()(2, 0)) < 1e-12,
"transpose");
290 logger.assert_always(std::abs(A23(1, 2) - A23.transpose()(2, 1)) < 1e-12,
"transpose");
292 auto data = A23.data();
293 logger.assert_always(std::abs(data[0] - A23[0]) < 1e-12,
"data");
294 logger.assert_always(std::abs(data[1] - A23[1]) < 1e-12,
"data");
295 logger.assert_always(std::abs(data[2] - A23[2]) < 1e-12,
"data");
296 logger.assert_always(std::abs(data[3] - A23[3]) < 1e-12,
"data");
297 logger.assert_always(std::abs(data[4] - A23[4]) < 1e-12,
"data");
298 logger.assert_always(std::abs(data[5] - A23[5]) < 1e-12,
"data");
300 logger.assert_always(std::abs(A23[2] - 17.3) < 1e-12,
"data");
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Data type for small dense matrix.
Definition: SmallMatrix.h:68
unsigned int getNCols() const
Definition: SmallMatrix.h:298
unsigned int size() const
Get total number of Matrix entries.
Definition: SmallMatrix.h:275
unsigned int getNumberOfRows() const
Get the number of rows.
Definition: SmallMatrix.h:281
void axpy(Mdouble a, const SmallMatrix &x)
Applies the matrix y=ax + y, where x is another matrix and a is a scalar.
Definition: SmallMatrix.h:266
Definition: SmallVector.h:62
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51