todo and some other stuff

This commit is contained in:
Barrett Ruth 2025-08-30 18:54:04 -05:00
parent 12693fc20f
commit 6f5ed47f3f
3 changed files with 29 additions and 38 deletions

View file

@ -1,3 +1,9 @@
# bmath
header-only c++ 23 math library
## todo
[] sieves
[] factorization
[] `std::unsigned_integral` as modulus type

View file

@ -1,38 +0,0 @@
#include <cassert>
#include <cstdint>
#include <iostream>
#include "../include/bmath.hh"
using namespace bmath;
using namespace std;
int main() {
constexpr uint64_t four{4}, five{5};
constexpr mint<uint64_t> mintfour{four};
constexpr mint<uint64_t> mintfive{five};
constexpr auto mintnine = mintfour + mintfive;
// static_assert(mintnine == four + five);
// static_assert(4 + 5 == mint<uint64_t>{9});
static_assert(mint<uint64_t, 100000>{8} ==
mint<uint64_t, 100000>{4} + mint<uint64_t, 100000>{4});
static_assert(is_trivially_copyable_v<mint<uint64_t>>);
// pow(mint<int>{2}, 0);
// cout << (std::format("x: {}\n", mintfour));
// auto res = mint<int>{4} + mint<int, 5>{4};
// cout << (mint<int, 4>{5} + mint<int, 4>{7});
// cout << pow(mint<int, 5>{4}, 5);
// cout << to_string(pow(mint<int>{5}, 5));
mint<int> x{5};
return 0;
}

23
tests/test_compilation.cc Normal file
View file

@ -0,0 +1,23 @@
#include <cassert>
#include <cstdint>
#include <iostream>
#include "../include/bmath.hh"
using namespace bmath;
using namespace std;
int main() {
mint<uint64_t> four{4};
// should be trivially copyable
static_assert(is_trivially_copyable_v<mint<uint64_t>>);
// should be able to format
auto formatted = format("{}\n", four);
// and use to_string
formatted = to_string(four);
return 0;
}