mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
moved TYPE checks to tests
This commit is contained in:
parent
f5cd82db8c
commit
485f6afe42
2 changed files with 4 additions and 4 deletions
|
|
@ -6,15 +6,11 @@ Copyright 2024 Ahmet Inan <inan@aicodix.de>
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace CODE {
|
||||
|
||||
template <typename TYPE, TYPE PRIME>
|
||||
struct PrimeField
|
||||
{
|
||||
static_assert(std::is_unsigned<TYPE>::value, "TYPE must be unsigned");
|
||||
static_assert(std::numeric_limits<TYPE>::max() / (PRIME-1) >= (PRIME-1), "Type not wide enough");
|
||||
static constexpr TYPE P = PRIME;
|
||||
TYPE v;
|
||||
PrimeField() = default;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,18 @@ Test for the prime field arithmetic
|
|||
Copyright 2024 Ahmet Inan <inan@aicodix.de>
|
||||
*/
|
||||
|
||||
#include <limits>
|
||||
#include <cstdint>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
#include "prime_field.hh"
|
||||
|
||||
template <typename TYPE, TYPE PRIME>
|
||||
void exhaustive_test()
|
||||
{
|
||||
assert(std::is_unsigned<TYPE>::value);
|
||||
assert(std::numeric_limits<TYPE>::max() / (PRIME-1) >= (PRIME-1));
|
||||
typedef CODE::PrimeField<TYPE, PRIME> PF;
|
||||
for (TYPE a = 0; a < PRIME; ++a)
|
||||
for (TYPE b = 0; b < PRIME; ++b)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue