Add option to be PEDANTIC©

This commit is contained in:
Camille Monière 2022-02-15 19:25:45 +01:00
parent 1027b8fc09
commit 0947b52266
Signed by: moniere
GPG key ID: 188DD5B072181C0F
3 changed files with 11 additions and 13 deletions

View file

@ -23,8 +23,15 @@ option (EXPORT_COMMANDS "export compile commands, for use with clangd for exampl
option (ENABLE_XILINX "use Xilinx provided and proprietary headers." OFF)
option (ENABLE_TESTING "use Catch2 in conjunction with CTest as a test suite." ON)
option (PEDANTIC "use -Wall and -pedantic." ON)
####################################################################################################
if (PEDANTIC)
add_compile_options(-Wall -pedantic)
endif ()
if (EXPORT_COMMANDS)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif ()

View file

@ -40,7 +40,7 @@ private:
double B = 0;
uint8_t R = 0;
uint8_t mask = 0x80;
const uint8_t sig_mask = 0x80;
double beta = rot_in;
@ -57,12 +57,12 @@ private:
}
if ((beta < -half_pi) || (beta > half_pi)) {
R = R | mask;
R = R | sig_mask;
beta = beta < 0 ? beta + pi : beta - pi;
// A = -A;
// B = -B;
} else {
R = R & (~mask);
R = R & (~sig_mask);
}
for (uint8_t u = 1; u < NStages + 1; u++) {
@ -77,7 +77,7 @@ private:
const double sigma = beta < 0 ? -1. : 1;
R = beta < 0 ? R | mask : R & ~mask;
R = beta < 0 ? R | mask : R & nmask;
const double factor = sigma / double(1U << (u - 1));

View file

@ -301,22 +301,13 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
}
TEST_CASE("ROM-based Cordic constexpr are evaluated during compilation.", "[CORDIC]") {
constexpr unsigned n_lines = 100000;
SECTION("W:16 - I:4 - Stages:6 - q:64 - C-Types") {
static constexpr cordic_rom cordic {};
constexpr double rotation = cordic_rom::rom_cordic.rotation;
constexpr double q = cordic_rom::rom_cordic.q;
constexpr uint64_t max_length = cordic_rom::rom_cordic.max_length;
constexpr complex<int64_t> value_in = (1U << 12) * 97;
constexpr uint8_t angle = 169;
double results_re[n_lines];
double results_im[n_lines];
constexpr complex<int64_t> res1 = cordic.cordic(value_in, angle);
constexpr complex<int64_t> res2 = cordic.cordic(value_in, angle);
static_assert(res1 == res2, "Test");