Skip to content

Commit

Permalink
Update use of CNL to reflect static_integer changes (hbe72#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmcfarlane authored and hbe72 committed Jun 28, 2019
1 parent fbababc commit c259278
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ message("-- INT128 = ${INT128}")
message("-- STD = ${STD}")
message("-- EXCEPTIONS = ${EXCEPTIONS}")

set(CNL_GIT_TAG_DEFAULT b89764fb4845cc3a5e880e00d0c463520ee3ff92)
set(CNL_GIT_TAG_DEFAULT 6cd6ad26786f767dd75ca7111a98ba83f0e39dff)
set(CNL_GIT_TAG_ENV $ENV{CDSP_CNL_GIT_TAG})
set(CNL_GIT_TAG "" CACHE BOOL "specify which revision of CNL to use")

Expand Down
8 changes: 4 additions & 4 deletions include/cdsp/trig.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ std::size_t trig<T>::get_twopi_index()
template<class T>
T trig<T>::sin_turn(T turn)
{
auto mul = static_cast<cnl::elastic_number<TABLE_SIZE_IN_TWOS_POWER+2,0>>(TWOPI_INDEX);
auto mul = static_cast<cnl::elastic_scaled_integer<TABLE_SIZE_IN_TWOS_POWER+2,0>>(TWOPI_INDEX);
auto index = static_cast<unsigned int>(cdsp::math::floor(turn * mul));
T fra = turn * mul - index;
T lo = sin_at(static_cast<std::size_t>(index));
Expand All @@ -123,7 +123,7 @@ T trig<T>::sin_turn(T turn)
template<class T>
T trig<T>::cos_turn(T turn)
{
auto mul = static_cast<cnl::elastic_number<TABLE_SIZE_IN_TWOS_POWER+2,0>>(TWOPI_INDEX);
auto mul = static_cast<cnl::elastic_scaled_integer<TABLE_SIZE_IN_TWOS_POWER+2,0>>(TWOPI_INDEX);
auto index = static_cast<unsigned int>(cdsp::math::floor(turn * mul));
T fra = turn * mul - index;
T lo = cos_at(static_cast<std::size_t>(index));
Expand All @@ -136,7 +136,7 @@ T trig<T>::cos_turn(T turn)
template<class T>
complex<T> trig<T>::exp_turn(T turn)
{
auto mul = static_cast<cnl::elastic_number<TABLE_SIZE_IN_TWOS_POWER+2,0>>(TWOPI_INDEX);
auto mul = static_cast<cnl::elastic_scaled_integer<TABLE_SIZE_IN_TWOS_POWER+2,0>>(TWOPI_INDEX);
auto index = static_cast<unsigned int>(cdsp::math::floor(turn * mul));
T fra = turn * mul - index;
complex<T> lo = operator[](index);
Expand Down Expand Up @@ -218,4 +218,4 @@ complex<T> trig<T>::operator[](std::size_t index)
}

} // namespace cdsp
#endif // CDSP_TRIG
#endif // CDSP_TRIG
20 changes: 10 additions & 10 deletions test/basic_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ TEST(basic_math, rounding_fixed_point)

TEST(basic_math, rounding_elastic_number)
{

using q4_4 = cdsp::rounding_elastic_number<8, -4>;
using q4_1 = cdsp::rounding_elastic_number<4, -1>;

q4_4 a(0.4375);
q4_1 b = a;
EXPECT_EQ(a, 0.4375);
Expand Down Expand Up @@ -111,14 +111,14 @@ namespace test_rounding_should_stay_under_64_bits

namespace test_convert_nearest_rounding_elastic_number
{
static constexpr auto a = cnl::elastic_number<8, -4>{0.3125};
static constexpr auto b = cnl::convert<cnl::nearest_rounding_tag, cnl::elastic_number<4, -1>>(a);
static_assert(identical(cnl::elastic_number<4, -1>{0.5}, b),
"cnl::convert<nearest_rounding_tag, elastic_number, elastic_number>");

static constexpr auto c = cnl::convert<cnl::nearest_rounding_tag, cnl::elastic_number<4, -2>>(a);
static_assert(identical(cnl::elastic_number<4, -2>{0.25}, c),
"cnl::convert<nearest_rounding_tag, elastic_number, elastic_number>");
static constexpr auto a = cnl::elastic_scaled_integer<8, -4>{0.3125};
static constexpr auto b = cnl::convert<cnl::nearest_rounding_tag, cnl::elastic_scaled_integer<4, -1>>(a);
static_assert(identical(cnl::elastic_scaled_integer<4, -1>{0.5}, b),
"cnl::convert<nearest_rounding_tag, elastic_scaled_integer, elastic_scaled_integer>");

static constexpr auto c = cnl::convert<cnl::nearest_rounding_tag, cnl::elastic_scaled_integer<4, -2>>(a);
static_assert(identical(cnl::elastic_scaled_integer<4, -2>{0.25}, c),
"cnl::convert<nearest_rounding_tag, elastic_scaled_integer, elastic_scaled_integer>");
}

namespace test_convert_nearest_rounding_fixed_point
Expand Down

0 comments on commit c259278

Please sign in to comment.