Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
elsa
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
34
Issues
34
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
10
Merge Requests
10
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IP
elsa
Commits
2eef2f45
Commit
2eef2f45
authored
Apr 09, 2020
by
Tobias Lasser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Changes
3
Pipelines
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
18 deletions
+32
-18
elsa/test_routines/CMakeLists.txt
elsa/test_routines/CMakeLists.txt
+2
-2
elsa/test_routines/testHelpers.cpp
elsa/test_routines/testHelpers.cpp
+26
-0
elsa/test_routines/testHelpers.h
elsa/test_routines/testHelpers.h
+4
-16
No files found.
elsa/test_routines/CMakeLists.txt
View file @
2eef2f45
...
...
@@ -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
elsa/test_routines/testHelpers.cpp
0 → 100644
View file @
2eef2f45
#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
elsa/test_routines/testHelpers.h
View file @
2eef2f45
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment