Skip to content

Commit dcd04cd

Browse files
Tests: add xGGQRCS test with random matrices
1 parent db2ee86 commit dcd04cd

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

TESTING/cpp/ggqrcs.hpp

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
#include <algorithm>
4343
#include <limits>
4444
#include <cmath>
45-
46-
#include <iostream>
47-
#include <boost/numeric/ublas/io.hpp>
45+
#include <random>
4846

4947

5048

@@ -468,6 +466,70 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
468466
}
469467
}
470468

469+
470+
471+
BOOST_AUTO_TEST_CASE_TEMPLATE(
472+
ggqrcs_random_test, T, test_types)
473+
{
474+
const std::size_t dimensions[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
475+
476+
for(std::size_t m : dimensions)
477+
{
478+
for(std::size_t n : dimensions)
479+
{
480+
for(std::size_t p : dimensions)
481+
{
482+
std::mt19937_64 gen( 1u );
483+
std::uniform_real_distribution<T> dist(-1, +1);
484+
auto make_rand = [&gen, &dist] (T s)
485+
{
486+
auto rand = [&gen, &dist, s] () { return s*dist(gen); };
487+
return rand;
488+
};
489+
490+
491+
for(std::size_t iter = 0; iter < 100; ++iter)
492+
{
493+
Fixture<T> fixture(m, n, p);
494+
495+
auto A = fixture.A;
496+
auto B = fixture.B;
497+
498+
std::generate(
499+
A.data().begin(), A.data().end(), make_rand(1000) );
500+
std::generate(
501+
B.data().begin(), B.data().end(), make_rand(1) );
502+
503+
fixture.A = A;
504+
fixture.B = B;
505+
506+
auto& theta = fixture.theta;
507+
auto& U1 = fixture.U1;
508+
auto& U2 = fixture.U2;
509+
auto& Qt = fixture.Qt;
510+
auto& work = fixture.work;
511+
auto& iwork = fixture.iwork;
512+
513+
const Integer lwork = work.size();
514+
double w = -1;
515+
Integer l = -1;
516+
517+
Integer ret = lapack::ggqrcs(
518+
'Y', 'Y', 'Y', m, n, p, &w, &l,
519+
&A(0, 0), m, &B(0, 0), p,
520+
&theta(0),
521+
&U1(0, 0), m, &U2(0, 0), p, &Qt(0, 0), n,
522+
&work(0), lwork, &iwork(0) );
523+
524+
check_results(
525+
ret, fixture.A, fixture.B,
526+
w, l, theta, U1, U2, Qt, A, B);
527+
}
528+
}
529+
}
530+
}
531+
}
532+
471533
BOOST_AUTO_TEST_SUITE_END()
472534

473535
#endif

0 commit comments

Comments
 (0)