Macaulay2 Engine
Loading...
Searching...
No Matches
aring-CCC.cpp
Go to the documentation of this file.
1#include "aring-CCC.hpp"
2#include "text-io.hpp"
3
4namespace M2 {
5
6void ARingCCC::text_out(buffer &o) const { o << "ACCC_" << get_precision(); }
8 const ElementType &f,
9 bool p_one,
10 bool p_plus,
11 bool p_parens) const
12{
13 if (p_plus && (mpfr_cmp_si(&f.re, 0) > 0 ||
14 (mpfr_cmp_si(&f.re, 0) == 0 && mpfr_cmp_si(&f.im, 0) > 0)))
15 o << "+";
16
17 if (p_parens && mpfr_cmp_si(&f.re, 0) != 0 && mpfr_cmp_si(&f.im, 0) != 0) {
18 if (mpfr_cmp_si(&f.re, 0) < 0) {
19 ElementType neg;
20
21 init(neg);
22 negate(neg, f);
23 o << "-(" << &neg << ")";
24 clear(neg);
25 } else {
26 o << "(" << &f << ")";
27 }
28 } else {
29 if (!p_one && mpfr_cmp_si(&f.re, -1) == 0 && mpfr_cmp_si(&f.im, 0) == 0)
30 o << "-";
31 else if (p_one || mpfr_cmp_si(&f.re, 1) != 0 || mpfr_cmp_si(&f.im, 0) != 0)
32 o << &f;
33 }
34}
35
36}; // end namespace M2
37
38// Local Variables:
39// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
40// indent-tabs-mode: nil
41// End:
M2::ARingCCC — arbitrary-precision complex numbers (pair of MPFR floats).
void text_out(buffer &o) const
Definition aring-CCC.cpp:6
void init(ElementType &result) const
void negate(ElementType &result, const ElementType &a) const
unsigned long get_precision() const
Definition aring-CCC.hpp:88
static void clear(ElementType &result)
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
Definition aring-CCC.cpp:7
Definition aring-CC.cpp:3
__mpfr_struct im
Definition ringelem.hpp:58
__mpfr_struct re
Definition ringelem.hpp:57
Text-formatting helpers layered on buffer: bignum print, line wrapping, M2_gbTrace-gated emit.