Skip to content

Commit

Permalink
Tests: add xGGQRCS test with random matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-conrads committed Sep 30, 2016
1 parent db2ee86 commit dcd04cd
Showing 1 changed file with 65 additions and 3 deletions.
68 changes: 65 additions & 3 deletions TESTING/cpp/ggqrcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
#include <algorithm>
#include <limits>
#include <cmath>

#include <iostream>
#include <boost/numeric/ublas/io.hpp>
#include <random>



Expand Down Expand Up @@ -468,6 +466,70 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
}
}



BOOST_AUTO_TEST_CASE_TEMPLATE(
ggqrcs_random_test, T, test_types)
{
const std::size_t dimensions[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

for(std::size_t m : dimensions)
{
for(std::size_t n : dimensions)
{
for(std::size_t p : dimensions)
{
std::mt19937_64 gen( 1u );
std::uniform_real_distribution<T> dist(-1, +1);
auto make_rand = [&gen, &dist] (T s)
{
auto rand = [&gen, &dist, s] () { return s*dist(gen); };
return rand;
};


for(std::size_t iter = 0; iter < 100; ++iter)
{
Fixture<T> fixture(m, n, p);

auto A = fixture.A;
auto B = fixture.B;

std::generate(
A.data().begin(), A.data().end(), make_rand(1000) );
std::generate(
B.data().begin(), B.data().end(), make_rand(1) );

fixture.A = A;
fixture.B = B;

auto& theta = fixture.theta;
auto& U1 = fixture.U1;
auto& U2 = fixture.U2;
auto& Qt = fixture.Qt;
auto& work = fixture.work;
auto& iwork = fixture.iwork;

const Integer lwork = work.size();
double w = -1;
Integer l = -1;

Integer ret = lapack::ggqrcs(
'Y', 'Y', 'Y', m, n, p, &w, &l,
&A(0, 0), m, &B(0, 0), p,
&theta(0),
&U1(0, 0), m, &U2(0, 0), p, &Qt(0, 0), n,
&work(0), lwork, &iwork(0) );

check_results(
ret, fixture.A, fixture.B,
w, l, theta, U1, U2, Qt, A, B);
}
}
}
}
}

BOOST_AUTO_TEST_SUITE_END()

#endif

0 comments on commit dcd04cd

Please sign in to comment.