Skip to content

Commit

Permalink
Separate legacy diagonalisation tests out from other tests
Browse files Browse the repository at this point in the history
and also always run CKM tests
  • Loading branch information
Dylan Harries committed Mar 10, 2017
1 parent 28de6db commit e1b8a76
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 71 deletions.
12 changes: 8 additions & 4 deletions test/module.mk
Expand Up @@ -19,6 +19,7 @@ LIBTEST := $(DIR)/lib$(MODNAME)$(MODULE_LIBEXT)
TEST_SRC := \
$(DIR)/test_array_view.cpp \
$(DIR)/test_cast_model.cpp \
$(DIR)/test_ckm.cpp \
$(DIR)/test_logger.cpp \
$(DIR)/test_derivative.cpp \
$(DIR)/test_effective_couplings.cpp \
Expand All @@ -43,6 +44,7 @@ TEST_SRC := \
$(DIR)/test_thread_pool.cpp \
$(DIR)/test_threshold_loop_functions.cpp \
$(DIR)/test_which.cpp \
$(DIR)/test_wrappers.cpp

TEST_SH := \
$(DIR)/test_depgen.sh \
Expand All @@ -62,13 +64,12 @@ TEST_SRC += \
ifeq ($(WITH_SoftsusyMSSM),yes)
TEST_SRC += \
$(DIR)/test_betafunction.cpp \
$(DIR)/test_ckm.cpp \
$(DIR)/test_legacy_diagonalization.cpp \
$(DIR)/test_lowe.cpp \
$(DIR)/test_QedQcd.cpp \
$(DIR)/test_rk.cpp \
$(DIR)/test_two_scale_mssm_solver.cpp \
$(DIR)/test_two_scale_mssm_initial_guesser.cpp \
$(DIR)/test_wrappers.cpp
$(DIR)/test_two_scale_mssm_initial_guesser.cpp
endif

ifeq ($(WITH_SM) $(WITH_SoftsusyMSSM),yes yes)
Expand Down Expand Up @@ -622,7 +623,10 @@ $(DIR)/test_thread_pool.x: $(DIR)/test_thread_pool.o $(LIBFLEXI) $(filter-out -%
$(DIR)/test_threshold_loop_functions.x: $(DIR)/test_threshold_loop_functions.o $(LIBFLEXI) $(filter-out -%,$(LOOPFUNCLIBS)) $(LIBTEST)
$(CXX) -o $@ $(call abspathx,$^) $(filter -%,$(LOOPFUNCLIBS)) $(BOOSTTESTLIBS) $(BOOSTTHREADLIBS) $(FLIBS) $(LIBTEST)

$(DIR)/test_wrappers.x: $(DIR)/test_wrappers.o $(LIBSoftsusyMSSM) $(LIBFLEXI) $(filter-out -%,$(LOOPFUNCLIBS)) $(LIBTEST)
$(DIR)/test_wrappers.x: $(DIR)/test_wrappers.o $(LIBFLEXI) $(filter-out -%,$(LOOPFUNCLIBS)) $(LIBTEST)
$(CXX) -o $@ $(call abspathx,$^) $(filter -%,$(LOOPFUNCLIBS)) $(BOOSTTESTLIBS) $(BOOSTTHREADLIBS) $(FLIBS) $(LIBTEST)

$(DIR)/test_legacy_diagonalization.x: $(DIR)/test_legacy_diagonalization.o $(LIBSoftsusyMSSM) $(LIBFLEXI) $(filter-out -%,$(LOOPFUNCLIBS)) $(LIBTEST)
$(CXX) -o $@ $(call abspathx,$^) $(filter -%,$(LOOPFUNCLIBS)) $(BOOSTTESTLIBS) $(BOOSTTHREADLIBS) $(FLIBS) $(LIBTEST)

$(DIR)/test_sum.x: $(DIR)/test_sum.o $(LIBFLEXI) $(filter-out -%,$(LOOPFUNCLIBS)) $(LIBTEST)
Expand Down
84 changes: 84 additions & 0 deletions test/test_legacy_diagonalization.cpp
@@ -0,0 +1,84 @@
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE test_legacy_diagonalization

#include <boost/test/unit_test.hpp>

#include "diagonalization.hpp"

#include <random>

using namespace softsusy;

DoubleMatrix random_real_matrix(int n, int m)
{
static std::default_random_engine generator;
static std::uniform_real_distribution<> o1(-3, 3);

DoubleMatrix r(n, m);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
r(i, j) = o1(generator);
}
}
return r;
}

BOOST_AUTO_TEST_CASE( test_svd )
{
for (int n = 2; n <= 6; ++n) {
DoubleMatrix m(n,n);
ComplexMatrix u(n,n);
ComplexMatrix v(n,n);
DoubleVector s(n);
ComplexMatrix diag(n,n);

for (int count = 100; count; --count) {
m = random_real_matrix(n,n);
if (n == 2) {
flexiblesusy::Diagonalize2by2(m, u, v, s);
} else {
flexiblesusy::Diagonalize(m, u, v, s);
}
diag = u.complexConjugate() * m * v.hermitianConjugate();

for (int i = 1; i <= s.displayEnd(); ++i) {
BOOST_CHECK(s(i) >= 0);
}
for (int i = 1; i <= diag.displayCols(); ++i) {
for (int j = 1; j <= diag.displayRows(); ++j) {
BOOST_CHECK_SMALL(abs(diag(i,j) - (i==j?s(i):0)), 1e-13);
}
}
}
}
}

BOOST_AUTO_TEST_CASE( test_symmetric )
{
for (int n = 2; n <= 6; ++n) {
DoubleMatrix m(n,n);
ComplexMatrix u(n,n);
DoubleVector s(n);
ComplexMatrix diag(n,n);

for (int count = 100; count; --count) {
m = random_real_matrix(n,n);
m.symmetrise();
if (n == 2) {
flexiblesusy::Diagonalize2by2(m, u, s);
} else {
flexiblesusy::Diagonalize(m, u, s);
}
diag = u.complexConjugate() * m * u.hermitianConjugate();

for (int i = 1; i <= s.displayEnd(); ++i) {
BOOST_CHECK(s(i) >= 0);
}
for (int i = 1; i <= diag.displayCols(); ++i) {
for (int j = 1; j <= diag.displayRows(); ++j) {
BOOST_CHECK_SMALL(abs(diag(i,j) - (i==j?s(i):0)), 1e-13);
}
}
}
}
}
67 changes: 0 additions & 67 deletions test/test_wrappers.cpp
Expand Up @@ -19,11 +19,9 @@
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE test_wrappers

#include <random>
#include <complex>
#include <boost/test/unit_test.hpp>
#include "wrappers.hpp"
#include "diagonalization.hpp"
#include "stopwatch.hpp"
#include <boost/lexical_cast.hpp>

Expand All @@ -36,7 +34,6 @@
#endif

using namespace flexiblesusy;
using namespace softsusy;

BOOST_AUTO_TEST_CASE( test_Delta )
{
Expand Down Expand Up @@ -73,70 +70,6 @@ BOOST_AUTO_TEST_CASE( test_UnitStep )

using namespace std;

DoubleMatrix random_real_matrix(int n, int m)
{
static default_random_engine generator;
static uniform_real_distribution<> o1(-3, 3);

DoubleMatrix r(n, m);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
r(i, j) = o1(generator);
return r;
}

BOOST_AUTO_TEST_CASE(test_svd)
{
for (int n = 2; n <= 6; n++) {
DoubleMatrix m(n,n);
ComplexMatrix u(n,n);
ComplexMatrix v(n,n);
DoubleVector s(n);
ComplexMatrix diag(n,n);

for (int count = 100; count; count--) {
m = random_real_matrix(n,n);
if (n == 2)
Diagonalize2by2(m, u, v, s);
else
Diagonalize(m, u, v, s);
diag = u.complexConjugate() * m * v.hermitianConjugate();

for (int i = 1; i <= s.displayEnd(); i++)
BOOST_CHECK(s(i) >= 0);
for (int i = 1; i <= diag.displayCols(); i++)
for (int j = 1; j <= diag.displayRows(); j++)
BOOST_CHECK_SMALL(abs(diag(i,j) - (i==j?s(i):0)), 1e-13);
}
}
}

BOOST_AUTO_TEST_CASE(test_symmetric)
{
for (int n = 2; n <= 6; n++) {
DoubleMatrix m(n,n);
ComplexMatrix u(n,n);
DoubleVector s(n);
ComplexMatrix diag(n,n);

for (int count = 100; count; count--) {
m = random_real_matrix(n,n);
m.symmetrise();
if (n == 2)
Diagonalize2by2(m, u, s);
else
Diagonalize(m, u, s);
diag = u.complexConjugate() * m * u.hermitianConjugate();

for (int i = 1; i <= s.displayEnd(); i++)
BOOST_CHECK(s(i) >= 0);
for (int i = 1; i <= diag.displayCols(); i++)
for (int j = 1; j <= diag.displayRows(); j++)
BOOST_CHECK_SMALL(abs(diag(i,j) - (i==j?s(i):0)), 1e-13);
}
}
}

BOOST_AUTO_TEST_CASE(test_Diag)
{
Eigen::Matrix<double,3,3> m;
Expand Down

0 comments on commit e1b8a76

Please sign in to comment.