Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100315104
test.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jan 29, 21:46
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Jan 31, 21:46 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23948397
Attached To
rTAMAAS tamaas
test.hh
View Options
/**
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "tamaas.hh"
#include <algorithm>
#include <criterion/criterion.h>
#include <fftw3.h>
#include <thrust/complex.h>
#include <utility>
void
tamaas_init
()
{
tamaas
::
initialize
();
}
void
tamaas_teardown
()
{
tamaas
::
finalize
();
}
template
<
typename
T
,
typename
U
>
bool
compare
(
T
&&
a
,
U
&&
b
)
{
return
std
::
mismatch
(
std
::
begin
(
a
),
std
::
end
(
a
),
std
::
begin
(
b
))
==
std
::
make_pair
(
std
::
end
(
a
),
std
::
end
(
b
));
}
template
<
typename
T
,
typename
U
,
typename
Pred
>
bool
compare
(
T
&&
a
,
U
&&
b
,
Pred
&&
pred
)
{
return
std
::
mismatch
(
std
::
begin
(
a
),
std
::
end
(
a
),
std
::
begin
(
b
),
pred
)
==
std
::
make_pair
(
std
::
end
(
a
),
std
::
end
(
b
));
}
struct
AreFloatEqual
{
template
<
typename
T
,
typename
U
>
inline
bool
operator
()(
T
&&
_x
,
U
&&
_y
)
{
tamaas
::
Real
x
=
_x
;
tamaas
::
Real
y
=
_y
;
// T y = reinterpret_cast<T>(z);
tamaas
::
Real
tolerance
=
1e-12
;
tamaas
::
Real
abs_max
=
std
::
max
(
std
::
abs
(
x
),
std
::
abs
(
y
));
abs_max
=
std
::
max
(
abs_max
,
tamaas
::
Real
(
1.
));
return
std
::
abs
(
x
-
y
)
<=
(
tolerance
*
abs_max
);
}
};
struct
AreComplexEqual
{
inline
bool
operator
()(
const
tamaas
::
Complex
&
x
,
const
fftw_complex
&
y
)
{
auto
equal
=
AreFloatEqual
();
return
equal
(
x
.
real
(),
y
[
0
])
&&
equal
(
x
.
imag
(),
y
[
1
]);
}
};
Event Timeline
Log In to Comment