Commit 2eef2f45 authored by Tobias Lasser's avatar Tobias Lasser

fix test_routines to have a non-empty object file, fixes #59

parent 08448e7d
Pipeline #243641 passed with stages
in 57 minutes and 48 seconds
......@@ -12,7 +12,7 @@ set(MODULE_HEADERS
# list all the code files of the module
set(MODULE_SOURCES
)
testHelpers.cpp)
# build the module library
......@@ -32,4 +32,4 @@ target_compile_features(${ELSA_MODULE_TARGET_NAME} PUBLIC cxx_std_17)
# set -fPIC
set_target_properties(${ELSA_MODULE_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
# This is only used privately, so don't bother exporting it and installing it
\ No newline at end of file
# This is only used privately for the tests, so we don't bother exporting it and installing it
\ No newline at end of file
#include "testHelpers.h"
namespace elsa
{
template <typename data_t>
bool isApprox(const DataContainer<data_t>& x, const DataContainer<data_t>& y, real_t prec)
{
// check if size is the same, but do not throw an exception
assert(x.getSize() == y.getSize());
DataContainer<data_t> z = x;
z -= y;
data_t lhs = std::sqrt(z.squaredL2Norm());
data_t rhs = prec * std::sqrt(std::min(x.squaredL2Norm(), y.squaredL2Norm()));
return lhs <= rhs;
}
// ------------------------------------------
// explicit template instantiation
template bool isApprox(const DataContainer<float>& x, const DataContainer<float>& y,
real_t prec);
template bool isApprox(const DataContainer<double>& x, const DataContainer<double>& y,
real_t prec);
} // namespace elsa
......@@ -5,6 +5,7 @@
#include <random>
#include "elsaDefines.h"
#include "DataDescriptor.h"
#include "DataContainer.h"
#include <iomanip>
#include <limits>
......@@ -54,7 +55,7 @@ namespace elsa
* running into overflow issues.
*/
template <typename data_t>
auto generateRandomMatrix(const index_t size)
auto generateRandomMatrix(index_t size)
{
Eigen::Matrix<data_t, Eigen::Dynamic, 1> randVec(size);
......@@ -109,7 +110,6 @@ namespace elsa
return {dc, randVec};
}
/**
* \brief Compares two DataContainers using their norm. Computes \f$ \sqrt{\| x - y \|_{2}^2}
* \f$ and compares it to \f$ prec * \sqrt{min(\| x \|_{2}^2, \| y \|_{2}^2)} \f$. If the first
......@@ -122,20 +122,8 @@ namespace elsa
* @return true if the norms of the containers is approximate equal
*/
template <typename data_t>
bool isApprox(const elsa::DataContainer<data_t>& x, const elsa::DataContainer<data_t>& y,
real_t prec = Eigen::NumTraits<real_t>::dummy_precision())
{
// Check size is the same, don't throw an expection, as it is a programming error to pass
// containers with different size
assert(x.getSize() == y.getSize());
DataContainer<data_t> z = x;
z -= y;
data_t lhs = std::sqrt(z.squaredL2Norm());
data_t rhs = prec * std::sqrt(std::min(x.squaredL2Norm(), y.squaredL2Norm()));
return lhs <= rhs;
}
bool isApprox(const DataContainer<data_t>& x, const DataContainer<data_t>& y,
real_t prec = Eigen::NumTraits<real_t>::dummy_precision());
/**
* \brief Wrapper to remove const, volatile and reference of a type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment