-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharb_cc.h
42 lines (32 loc) · 918 Bytes
/
arb_cc.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
// C++ interface to arb_t
#pragma once
#include <flint/arb.h>
#include <string>
namespace mandelbrot {
using std::string;
struct Arb {
arb_t x;
Arb() { arb_init(x); }
Arb(const Arb& a) = delete;
explicit Arb(const arb_t a) { arb_init(x); arb_set(x, a); }
Arb(Arb&& a) { *x = *a.x; arb_init(a.x); }
~Arb() { arb_clear(x); }
// Assignment
void operator=(const slong a) { arb_set_si(x, a); }
void operator=(const Arb& a) { arb_set(x, a.x); }
void operator=(Arb&& a) { arb_swap(x, a.x); arb_zero(a.x); }
// Implicit converson
operator arb_ptr() { return x; }
operator arb_srcptr() const { return x; }
// Upper bound for |x|
friend double bound(const Arb& x);
// Printing
friend std::ostream& operator<<(std::ostream& out, const Arb& a);
string safe() const;
};
static inline Arb exact_arb(const double a) {
Arb x;
arb_set_d(x, a);
return x;
}
} // namespace mandelbrot