forked from Whirligig231/number-field-factorization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
numberfield.h
executable file
·66 lines (54 loc) · 1.93 KB
/
numberfield.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <gmp.h>
#include <gmpxx.h>
#include <vector>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <memory>
#include <Eigen/Core>
#include "numbers.h"
#include "polyring.h"
#include "modring.h"
#include "polymodring.h"
#pragma once
class numberfield {
private:
std::unique_ptr<mpq_class> rational_value;
std::unique_ptr<polymod<numberfield>> poly_value;
bool is_valid;
bool is_poly_value;
public:
numberfield();
numberfield(const mpq_class &value);
numberfield(const polymod<numberfield> &value);
numberfield(const numberfield &other);
bool is_poly() const;
mpq_class get_rational_value() const;
polymod<numberfield> get_poly_value() const;
numberfield &operator=(const mpq_class &value);
numberfield &operator=(const polymod<numberfield> &value);
numberfield &operator=(const numberfield &other);
bool operator==(const numberfield &other) const;
bool operator!=(const numberfield &other) const;
numberfield &operator+=(const numberfield &other);
numberfield &operator-=(const numberfield &other);
numberfield &operator*=(const numberfield &other);
numberfield &operator/=(const numberfield &other);
numberfield operator+(const numberfield &other) const;
numberfield operator-(const numberfield &other) const;
numberfield operator*(const numberfield &other) const;
numberfield operator/(const numberfield &other) const;
numberfield operator-() const;
numberfield inv() const;
friend std::ostream &operator<<(std::ostream &os, const numberfield &p);
};
template <>
class util<numberfield> {
public:
static numberfield zero();
static numberfield zero(const numberfield &reference);
static numberfield one();
static numberfield one(const numberfield &reference);
static numberfield from_int(int n, const numberfield &reference);
static numberfield get_gcd(numberfield a, numberfield b);
};