-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhprhelpers.h
72 lines (61 loc) · 2.54 KB
/
hprhelpers.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
67
68
69
70
71
72
// Copyright (c) 2012 Vadym Kliuchnikov sqct(dot)software(at)gmail(dot)com, Dmitri Maslov, Michele Mosca
//
// This file is part of SQCT.
//
// SQCT is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// SQCT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with SQCT. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef HPRHELPERS_H
#define HPRHELPERS_H
#include <gmpxx.h>
#define MPFR_REAL_DATA_PUBLIC
#include "real.hpp"
#include <complex>
typedef mpfr::real<256> hprr;
/// \brief Helper functions and data for high precision arithmetic
struct hprHelpers
{
typedef mpfr::real<256> hpr_real;
/// \brief High precision real type used in the project
/// \brief High precision complex type used in the project
typedef std::complex<hpr_real> hpr_complex;
/// \brief Transforms high precision complex number into machine complex
static void convert( const hpr_complex& from, std::complex<double>& to );
/// \brief Transforms high precision real number into double
static void convert( const hpr_real& from, double& to );
/// \brief Transforms high precision real number into double
static double toMachine( const hpr_real& from );
/// \brief Transforms high precision complex number into machine complex
static std::complex<double> toMachine( const hpr_complex& from );
/// \brief High precision \f$ \pi \f$
static const hpr_real& pi();
/// \brief High precision one
static const hpr_real& one();
/// \brief High precision one
static const hpr_real& two();
/// \brief High precision 1/2
static const hpr_real& half();
/// \brief High precision -1/2
static const hpr_real& mhalf();
/// \brief High precision \f$ \frac{\sqrt{2}}{2} \f$
static const hpr_real& sqrt2ov2();
/// \brief High precision \f$ \frac{\sqrt{2}}{2} \f$
static const hpr_real& sqrt2();
};
hprr pow2( int n );
long double to_ld( const hprr& a );
long to_long( const hprr& a );
mpz_class to_mpz( const hprr& a );
double to_double( const hprr& a );
hprr sqrt2pow( long p );
#endif // HPRHELPERS_H