BioCMAMC-ST
maths.hpp
1
#ifndef __BIOMC_COMMON_MATHS__
2
#define __BIOMC_COMMON_MATHS__
3
4
#include <Kokkos_Core.hpp>
5
6
namespace
CommonMaths
7
{
8
9
template
<
bool
use_kokkos_log>
10
KOKKOS_INLINE_FUNCTION
float
_ln
(
float
x)
11
requires
(!use_kokkos_log)
12
{
13
// NOLINTBEGIN
14
unsigned
int
bx = *
reinterpret_cast<
unsigned
int
*
>
(&x);
15
const
unsigned
int
ex = bx >> 23;
16
const
signed
int
t =
17
static_cast<
signed
int
>
(ex) -
static_cast<
signed
int
>
(127);
18
// unsigned int s = (t < 0) ? (-t) : t;
19
bx = 1065353216 | (bx & 8388607);
20
x = *
reinterpret_cast<
float
*
>
(&bx);
21
return
-1.49278 + (2.11263 + (-0.729104 + 0.10969 * x) * x) * x +
22
0.6931471806 * t;
23
// NOLINTEND
24
}
25
template
<
bool
use_kokkos_log>
26
KOKKOS_INLINE_FUNCTION
float
_ln
(
float
x)
27
requires
(use_kokkos_log)
28
{
29
return
Kokkos::log(x);
30
}
31
32
}
// namespace CommonMaths
33
#endif
CommonMaths
Definition
maths.hpp:7
CommonMaths::_ln
KOKKOS_INLINE_FUNCTION float _ln(float x)
Definition
maths.hpp:10
apps
libs
common
public
common
maths.hpp
Generated by
1.14.0