117 for (
size_t i = 0; i <
m1.GetNumRows(); ++i)
119 for (
size_t j = 0; j <
m1.GetNumCols(); ++j)
131 "The number of rows in resulting matrix is not correct");
134 "The number of cols in resulting matrix is not correct");
137 "The number of rows and cols should be equal");
144 "The element value should be " <<
m1.GetNumCols());
156 "The values are not equal");
178 "The number of rows in resulting matrix is not correct");
181 "The number of cols in resulting matrix is not correct");
184 "The number of rows and cols should be equal");
194 "The element value should be " << m5.
GetNumCols());
209 std::valarray<int> a{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
210 std::valarray<int> b{0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4};
211 std::valarray<T> aCasted(a.size());
212 std::valarray<T> bCasted(b.size());
213 for (
size_t i = 0; i < a.size(); ++i)
215 aCasted[i] =
static_cast<T
>(a[i]);
217 for (
size_t i = 0; i < b.size(); ++i)
219 bCasted[i] =
static_cast<T
>(b[i]);
227 NS_LOG_INFO(
"m8 (5, 3, 1) = m5.Transpose ()" << m8);
234 "Creation of vector is not correct.");
257 a = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
258 b = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
259 std::valarray<int> c{2, 3, 4, 6, 2, 3, 4, 6};
260 aCasted = std::valarray<T>(a.size());
261 bCasted = std::valarray<T>(b.size());
262 std::valarray<T> cCasted = std::valarray<T>(c.size());
264 for (
size_t i = 0; i < a.size(); ++i)
266 aCasted[i] =
static_cast<T
>(a[i]);
268 for (
size_t i = 0; i < b.size(); ++i)
270 bCasted[i] =
static_cast<T
>(b[i]);
272 for (
size_t i = 0; i < c.size(); ++i)
274 cCasted[i] =
static_cast<T
>(c[i]);
282 "The number of columns is not as expected.");
285 "The number of rows is not as expected.");
295 a = std::valarray<int>(
296 {0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5});
297 b = std::valarray<int>({0, 1, 0, 1, 0, 1, 0, 10, 0, 10, 0, 10});
298 c = std::valarray<int>({2, 3, 2, 3, 4, 6, 4, 6, 20, 30, 20, 30, 40, 60, 40, 60});
299 aCasted = std::valarray<T>(a.size());
300 bCasted = std::valarray<T>(b.size());
301 cCasted = std::valarray<T>(c.size());
303 for (
size_t i = 0; i < a.size(); ++i)
305 aCasted[i] =
static_cast<T
>(a[i]);
307 for (
size_t i = 0; i < b.size(); ++i)
309 bCasted[i] =
static_cast<T
>(b[i]);
311 for (
size_t i = 0; i < c.size(); ++i)
313 cCasted[i] =
static_cast<T
>(c[i]);
322 "The number of columns is not as expected.");
325 "The number of rows is not as expected.");
335 a = std::valarray<int>({5, 4, 5, 5, 4, 5});
336 b = std::valarray<int>({0, 1, 0, 1, 0, 1, 1, 2, 3, 10, 100, 1000});
337 c = std::valarray<int>({4, 10, 28, 5450});
338 aCasted = std::valarray<T>(a.size());
339 bCasted = std::valarray<T>(b.size());
340 cCasted = std::valarray<T>(c.size());
342 for (
size_t i = 0; i < a.size(); ++i)
344 aCasted[i] =
static_cast<T
>(a[i]);
346 for (
size_t i = 0; i < b.size(); ++i)
348 bCasted[i] =
static_cast<T
>(b[i]);
350 for (
size_t i = 0; i < c.size(); ++i)
352 cCasted[i] =
static_cast<T
>(c[i]);
361 "The number of columns is not as expected.");
364 "The number of rows is not as expected.");
371 std::valarray<int> d{1, 1, 1};
372 std::valarray<int> e{1, 1};
373 std::valarray<int> f{1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3};
374 std::valarray<int> g{12, 12};
375 std::valarray<T> dCasted(d.size());
376 std::valarray<T> eCasted(e.size());
377 std::valarray<T> fCasted(f.size());
378 std::valarray<T> gCasted(g.size());
379 for (
size_t i = 0; i < d.size(); ++i)
381 dCasted[i] =
static_cast<T
>(d[i]);
383 for (
size_t i = 0; i < e.size(); ++i)
385 eCasted[i] =
static_cast<T
>(e[i]);
387 for (
size_t i = 0; i < f.size(); ++i)
389 fCasted[i] =
static_cast<T
>(f[i]);
391 for (
size_t i = 0; i < g.size(); ++i)
393 gCasted[i] =
static_cast<T
>(g[i]);
403 std::valarray<int> h{1, 3, 2, 2, 4, 0};
404 std::valarray<int> j{2, 2, 3, 4, 1, 3, 0, 5};
405 std::valarray<int> k{1, 2, 0, 0, 2, 3, 4, 1, 2, 3, 4, 1, 1, 2, 0, 0, 2, 3, 4, 1, 2, 3, 4, 1};
406 std::valarray<int> l{144, 132, 128, 104, 144, 132, 128, 104};
407 std::valarray<T> hCasted(h.size());
408 std::valarray<T> jCasted(j.size());
409 std::valarray<T> kCasted(k.size());
410 std::valarray<T> lCasted(l.size());
411 for (
size_t i = 0; i < h.size(); ++i)
413 hCasted[i] =
static_cast<T
>(h[i]);
415 for (
size_t i = 0; i < j.size(); ++i)
417 jCasted[i] =
static_cast<T
>(j[i]);
419 for (
size_t i = 0; i < k.size(); ++i)
421 kCasted[i] =
static_cast<T
>(k[i]);
423 for (
size_t i = 0; i < l.size(); ++i)
425 lCasted[i] =
static_cast<T
>(l[i]);
439 size_t lCastedSize = lCasted.size();
440 NS_LOG_INFO(
"size() of lCasted before move: " << lCasted.size());
445 size_t hCastedSize = hCasted.size();
446 NS_LOG_INFO(
"size() of hCasted before move: " << hCasted.size());
451 size_t jCastedSize = jCasted.size();
452 NS_LOG_INFO(
"size() of jCasted before move: " << jCasted.size());
459 std::vector<std::pair<std::valarray<int>, T>> detTestCases{
461 {{1, 0, 7, 4, 2, 0, 6, 5, 3}, 62},
463 {{1, 4, 6, 0, 2, 5, 7, 0, 3}, 62},
465 {{1, 0, 0, 0, 1, 0, 0, 0, 1}, 1},
467 {{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, 1},
469 {{0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0}, -1},
471 {{36, -5, -5, 43}, 1523},
475 for (
const auto& [detVal, detRef] : detTestCases)
477 std::valarray<T> detCast(detVal.size());
479 auto side = sqrt(detVal.size());
482 static_cast<T
>(detRef),
483 "The determinants are not equal.");
487 std::valarray<int> multiPageMatrixValues{
518 std::valarray<T> castMultiPageMatrixValues(multiPageMatrixValues.size());
522 multiPageMatrixValues.size() / 9,
523 std::move(castMultiPageMatrixValues));
525 std::vector<int> determinants = {1, -1, 62, 60, -315, 4, 0};
527 for (
size_t page = 0; page < multiPageMatrix.
GetNumPages(); page++)
530 static_cast<T
>(determinants[page]),
531 "The determinants from the page " << std::to_string(page)
532 <<
" are not equal.");
536 std::vector<double> fnorms = {sqrt(3), sqrt(3), 11.8322, 15.3297, 14.7309, 3.4641, 2};
538 for (
size_t page = 0; page < multiPageMatrix.
GetNumPages(); page++)
541 std::abs(
static_cast<T
>(fnorms[page])),
543 "The Frobenius norm from the page " << std::to_string(page)
544 <<
" are not equal.");
548 for (
size_t noOfCopies = 1; noOfCopies < 4; noOfCopies++)
553 "Creating " << std::to_string(noOfCopies) <<
" copies failed.");
556 "The copy doesn't have the same number of rows as the original.");
559 "The copy doesn't have the same number of columns as the original.");
560 for (
size_t page = 0; page < copies.GetNumPages(); page++)
563 for (
size_t row = 0; row < copies.GetNumRows(); row++)
565 for (
size_t col = 0; col < copies.GetNumCols(); col++)
567 diff += m27(row, col, 0) - copies(row, col, page);
575 std::vector<MatrixArray<T>> pages{multiPageMatrix.
ExtractPage(1),
581 for (
size_t page = 0; page < jointPagesMatrix.GetNumPages(); page++)
584 for (
size_t row = 0; row < jointPagesMatrix.GetNumRows(); row++)
586 for (
size_t col = 0; col < jointPagesMatrix.GetNumCols(); col++)
588 diff += multiPageMatrix(row, col, 1 - page) - jointPagesMatrix(row, col, page);
595 auto identityRank3Reference = multiPageMatrix.
ExtractPage(0);