cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
algebraic_number.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Algebraic numbers
4
5
Author: Michael Tautschnig
6
7
\*******************************************************************/
8
9
#ifndef CPROVER_UTIL_ALGEBRAIC_NUMBER_H
10
#define CPROVER_UTIL_ALGEBRAIC_NUMBER_H
11
12
#include "
rational.h
"
13
#include "
std_expr.h
"
14
17
class
algebraic_numbert
18
{
19
protected
:
20
// the i-th entry is the coefficient of degree i
21
using
coefficientst
= std::vector<rationalt>;
22
coefficientst
coefficients
;
23
24
public
:
27
explicit
algebraic_numbert
(
const
std::vector<rationalt> &coeff)
28
:
coefficients
(coeff)
29
{
30
DATA_INVARIANT
(
coefficients
.size() >= 2,
"minimum degree is 1"
);
31
}
32
35
algebraic_numbert
() :
algebraic_numbert
({
rationalt
{0},
rationalt
{1}})
36
{
37
}
38
40
explicit
algebraic_numbert
(
const
rationalt
&
r
)
41
:
algebraic_numbert
({-
r
,
rationalt
{1}})
42
{
43
}
44
45
constant_exprt
as_expr
()
const
;
46
47
const
coefficientst
&
get_coefficients
()
const
48
{
49
return
coefficients
;
50
}
51
};
52
53
std::ostream &
operator<<
(std::ostream &out,
const
algebraic_numbert
&a);
54
55
#endif
// CPROVER_UTIL_ALGEBRAIC_NUMBER_H
operator<<
std::ostream & operator<<(std::ostream &out, const algebraic_numbert &a)
Definition
algebraic_number.cpp:34
algebraic_numbert
Represents real numbers as roots (zeros) of a polynomial with rational coefficients.
Definition
algebraic_number.h:18
algebraic_numbert::as_expr
constant_exprt as_expr() const
Definition
algebraic_number.cpp:17
algebraic_numbert::algebraic_numbert
algebraic_numbert()
The default constructor builds a algebraic_numbert representing real number 0.
Definition
algebraic_number.h:35
algebraic_numbert::algebraic_numbert
algebraic_numbert(const std::vector< rationalt > &coeff)
Represent a real number as roots of a polynomial with rational coefficients coeff.
Definition
algebraic_number.h:27
algebraic_numbert::coefficients
coefficientst coefficients
Definition
algebraic_number.h:22
algebraic_numbert::algebraic_numbert
algebraic_numbert(const rationalt &r)
Represent a rational number as algebraic_numbert.
Definition
algebraic_number.h:40
algebraic_numbert::coefficientst
std::vector< rationalt > coefficientst
Definition
algebraic_number.h:21
algebraic_numbert::get_coefficients
const coefficientst & get_coefficients() const
Definition
algebraic_number.h:47
rationalt
Definition
rational.h:16
r
static int8_t r
Definition
irep_hash.h:60
rational.h
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition
invariant.h:534
std_expr.h
API to expression classes.
util
algebraic_number.h
Generated by
1.17.0