Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F27036368
math.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
math.hpp
View Options
//===-- rosa/support/math.hpp -----------------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/support/math.hpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017
///
/// \brief Math helpers.
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_SUPPORT_MATH_HPP
#define ROSA_SUPPORT_MATH_HPP
#include
<cmath>
#include
<cstdlib>
#include
<limits>
#include
<type_traits>
namespace
rosa
{
/// Computes log base 2 of a number.
///
/// \param N the number to compute log base 2 for
///
/// \return log base 2 of \p N
constexpr
size_t
log2
(
const
size_t
N
)
{
return
((
N
<
2
)
?
1
:
1
+
log2
(
N
/
2
));
}
/// Tells the next representable floating point value.
///
/// \tparam T type to operate on
///
/// \note The second type argument enforces \p T being a floating point type,
/// always use the default value!
///
/// \param V value to which find the next representable one
///
/// \return the next representable value of type \p T after value \p V
///
/// \pre Type \p T must be a floating point type, which is enforced by
/// `std::enable_if` in the second type argument.
template
<
typename
T
,
typename
=
std
::
enable_if_t
<
std
::
is_floating_point
<
T
>::
value
>>
T
nextRepresentableFloatingPoint
(
const
T
V
)
{
return
std
::
nextafter
(
V
,
std
::
numeric_limits
<
T
>::
infinity
());
}
}
// End namespace rosa
#endif
// ROSA_SUPPORT_MATH_HPP
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Tue, Oct 27, 7:54 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
407821
Default Alt Text
math.hpp (1 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline