My Project  UNKNOWN_GIT_VERSION
Public Member Functions | Private Attributes | Friends
gmp_complex Class Reference

gmp_complex numbers based on More...

#include <mpr_complex.h>

Public Member Functions

 gmp_complex (const gmp_float re=0.0, const gmp_float im=0.0)
 
 gmp_complex (const mprfloat re, const mprfloat im=0.0)
 
 gmp_complex (const long re, const long im)
 
 gmp_complex (const gmp_complex &v)
 
 ~gmp_complex ()
 
gmp_complexneg ()
 
gmp_complexoperator+= (const gmp_complex &a)
 
gmp_complexoperator-= (const gmp_complex &a)
 
gmp_complexoperator*= (const gmp_complex &a)
 
gmp_complexoperator/= (const gmp_complex &a)
 
gmp_complexoperator= (const gmp_complex &a)
 
gmp_complexoperator= (const gmp_float &f)
 
gmp_float real () const
 
gmp_float imag () const
 
void real (gmp_float val)
 
void imag (gmp_float val)
 
bool isZero ()
 
void SmallToZero ()
 

Private Attributes

gmp_float r
 
gmp_float i
 

Friends

gmp_complex operator+ (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator- (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator* (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator/ (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator+ (const gmp_complex &a, const gmp_float b_d)
 
gmp_complex operator- (const gmp_complex &a, const gmp_float b_d)
 
gmp_complex operator* (const gmp_complex &a, const gmp_float b_d)
 
gmp_complex operator/ (const gmp_complex &a, const gmp_float b_d)
 
bool operator== (const gmp_complex &a, const gmp_complex &b)
 
bool operator> (const gmp_complex &a, const gmp_complex &b)
 
bool operator< (const gmp_complex &a, const gmp_complex &b)
 
bool operator>= (const gmp_complex &a, const gmp_complex &b)
 
bool operator<= (const gmp_complex &a, const gmp_complex &b)
 

Detailed Description

gmp_complex numbers based on

Definition at line 177 of file mpr_complex.h.

Constructor & Destructor Documentation

◆ gmp_complex() [1/4]

gmp_complex::gmp_complex ( const gmp_float  re = 0.0,
const gmp_float  im = 0.0 
)
inline

Definition at line 183 of file mpr_complex.h.

183  :
184  gmp_complex( const gmp_float re= 0.0, const gmp_float im= 0.0 )
185  {
186  r= re;
187  i= im;

◆ gmp_complex() [2/4]

gmp_complex::gmp_complex ( const mprfloat  re,
const mprfloat  im = 0.0 
)
inline

Definition at line 188 of file mpr_complex.h.

190  {
191  r= re;
192  i= im;

◆ gmp_complex() [3/4]

gmp_complex::gmp_complex ( const long  re,
const long  im 
)
inline

Definition at line 193 of file mpr_complex.h.

195  {
196  r= re;
197  i= im;

◆ gmp_complex() [4/4]

gmp_complex::gmp_complex ( const gmp_complex v)
inline

Definition at line 198 of file mpr_complex.h.

200  {
201  r= v.r;
202  i= v.i;

◆ ~gmp_complex()

gmp_complex::~gmp_complex ( )
inline

Definition at line 203 of file mpr_complex.h.

204 {}

Member Function Documentation

◆ imag() [1/2]

gmp_float gmp_complex::imag ( ) const
inline

Definition at line 234 of file mpr_complex.h.

234 { return r; }

◆ imag() [2/2]

void gmp_complex::imag ( gmp_float  val)
inline

Definition at line 237 of file mpr_complex.h.

237 { r = val; }

◆ isZero()

bool gmp_complex::isZero ( )
inline

Definition at line 240 of file mpr_complex.h.

241 { return (r.isZero() && i.isZero()); }

◆ neg()

gmp_complex & gmp_complex::neg ( )

Definition at line 660 of file mpr_complex.cc.

662 {
663  i.neg();
664  r.neg();
665  return *this;

◆ operator*=()

gmp_complex & gmp_complex::operator*= ( const gmp_complex a)

Definition at line 653 of file mpr_complex.cc.

655 {
656  gmp_float f = r * b.r - i * b.i;
657  i = r * b.i + i * b.r;
658  r = f;
659  return *this;

◆ operator+=()

gmp_complex & gmp_complex::operator+= ( const gmp_complex a)

Definition at line 641 of file mpr_complex.cc.

643 {
644  r+=b.r;
645  i+=b.i;
646  return *this;

◆ operator-=()

gmp_complex & gmp_complex::operator-= ( const gmp_complex a)

Definition at line 647 of file mpr_complex.cc.

649 {
650  r-=b.r;
651  i-=b.i;
652  return *this;

◆ operator/=()

gmp_complex & gmp_complex::operator/= ( const gmp_complex a)

Definition at line 666 of file mpr_complex.cc.

668 {
669  gmp_float d = b.r*b.r + b.i*b.i;
670  r = (r * b.r + i * b.i) / d;
671  i = (i * b.r - r * b.i) / d;
672  return *this;

◆ operator=() [1/2]

gmp_complex & gmp_complex::operator= ( const gmp_complex a)
inline

Definition at line 287 of file mpr_complex.h.

289 {
290  r= a.r;
291  i= a.i;
292  return *this;

◆ operator=() [2/2]

gmp_complex & gmp_complex::operator= ( const gmp_float f)
inline

Definition at line 295 of file mpr_complex.h.

297 {
298  r= f;
299  i= (long int)0;
300  return *this;

◆ real() [1/2]

gmp_float gmp_complex::real ( ) const
inline

Definition at line 233 of file mpr_complex.h.

234 { return r; }

◆ real() [2/2]

void gmp_complex::real ( gmp_float  val)
inline

Definition at line 236 of file mpr_complex.h.

237 { r = val; }

◆ SmallToZero()

void gmp_complex::SmallToZero ( )

Definition at line 784 of file mpr_complex.cc.

786 {
787  gmp_float ar=this->real();
788  gmp_float ai=this->imag();
789  if (ar.isZero() || ai.isZero()) return;
790  mpf_abs(*ar._mpfp(), *ar._mpfp());
791  mpf_abs(*ai._mpfp(), *ai._mpfp());
792  mpf_set_prec(*ar._mpfp(), 32);
793  mpf_set_prec(*ai._mpfp(), 32);
794  if (ar > ai)
795  {
796  mpf_div(*ai._mpfp(), *ai._mpfp(), *ar._mpfp());
797  if (ai < *gmpRel) this->imag(0.0);
798  }
799  else
800  {
801  mpf_div(*ar._mpfp(), *ar._mpfp(), *ai._mpfp());
802  if (ar < *gmpRel) this->real(0.0);
803  }

Friends And Related Function Documentation

◆ operator* [1/2]

gmp_complex operator* ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 627 of file mpr_complex.cc.

629 {
630  return gmp_complex( a.r * b.r - a.i * b.i,
631  a.r * b.i + a.i * b.r);

◆ operator* [2/2]

gmp_complex operator* ( const gmp_complex a,
const gmp_float  b_d 
)
friend

Definition at line 254 of file mpr_complex.h.

256 {
257  return gmp_complex( a.r * b_d, a.i * b_d );

◆ operator+ [1/2]

gmp_complex operator+ ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 619 of file mpr_complex.cc.

621 {
622  return gmp_complex( a.r + b.r, a.i + b.i );

◆ operator+ [2/2]

gmp_complex operator+ ( const gmp_complex a,
const gmp_float  b_d 
)
friend

Definition at line 246 of file mpr_complex.h.

248 {
249  return gmp_complex( a.r + b_d, a.i );

◆ operator- [1/2]

gmp_complex operator- ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 623 of file mpr_complex.cc.

625 {
626  return gmp_complex( a.r - b.r, a.i - b.i );

◆ operator- [2/2]

gmp_complex operator- ( const gmp_complex a,
const gmp_float  b_d 
)
friend

Definition at line 250 of file mpr_complex.h.

252 {
253  return gmp_complex( a.r - b_d, a.i );

◆ operator/ [1/2]

gmp_complex operator/ ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 632 of file mpr_complex.cc.

634 {
635  gmp_float d = b.r*b.r + b.i*b.i;
636  return gmp_complex( (a.r * b.r + a.i * b.i) / d,
637  (a.i * b.r - a.r * b.i) / d);

◆ operator/ [2/2]

gmp_complex operator/ ( const gmp_complex a,
const gmp_float  b_d 
)
friend

Definition at line 258 of file mpr_complex.h.

260 {
261  return gmp_complex( a.r / b_d, a.i / b_d );

◆ operator<

bool operator< ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 272 of file mpr_complex.h.

274 {
275  return ( a.real() < b.real() );

◆ operator<=

bool operator<= ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 280 of file mpr_complex.h.

282 {
283  return ( a.real() <= b.real() );

◆ operator==

bool operator== ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 264 of file mpr_complex.h.

266 {
267  return ( b.real() == a.real() ) && ( b.imag() == a.imag() );

◆ operator>

bool operator> ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 268 of file mpr_complex.h.

270 {
271  return ( a.real() > b.real() );

◆ operator>=

bool operator>= ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 276 of file mpr_complex.h.

278 {
279  return ( a.real() >= b.real() );

Field Documentation

◆ i

gmp_float gmp_complex::i
private

Definition at line 180 of file mpr_complex.h.

◆ r

gmp_float gmp_complex::r
private

Definition at line 180 of file mpr_complex.h.


The documentation for this class was generated from the following files:
f
FILE * f
Definition: checklibs.c:9
gmp_float::isZero
bool isZero() const
Definition: mpr_complex.cc:252
gmp_complex::r
gmp_float r
Definition: mpr_complex.h:180
gmp_complex::imag
gmp_float imag() const
Definition: mpr_complex.h:234
b
CanonicalForm b
Definition: cfModGcd.cc:4044
gmp_float::_mpfp
mpf_t * _mpfp()
Definition: mpr_complex.h:133
gmp_float::neg
gmp_float & neg()
Definition: mpr_complex.h:99
gmpRel
static gmp_float * gmpRel
Definition: mpr_complex.cc:44
gmp_complex::real
gmp_float real() const
Definition: mpr_complex.h:233
gmp_complex::i
gmp_float i
Definition: mpr_complex.h:180
gmp_complex::gmp_complex
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:183
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
gmp_float
Definition: mpr_complex.h:30