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 178 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 184 of file mpr_complex.h.

185  {
186  r= re;
187  i= im;
188  }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ gmp_complex() [2/4]

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

Definition at line 189 of file mpr_complex.h.

190  {
191  r= re;
192  i= im;
193  }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ gmp_complex() [3/4]

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

Definition at line 194 of file mpr_complex.h.

195  {
196  r= re;
197  i= im;
198  }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ gmp_complex() [4/4]

gmp_complex::gmp_complex ( const gmp_complex v)
inline

Definition at line 199 of file mpr_complex.h.

200  {
201  r= v.r;
202  i= v.i;
203  }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ ~gmp_complex()

gmp_complex::~gmp_complex ( )
inline

Definition at line 204 of file mpr_complex.h.

204 {}

Member Function Documentation

◆ imag() [1/2]

gmp_float gmp_complex::imag ( ) const
inline

Definition at line 235 of file mpr_complex.h.

235 { return i; }
gmp_float i
Definition: mpr_complex.h:181

◆ imag() [2/2]

void gmp_complex::imag ( gmp_float  val)
inline

Definition at line 238 of file mpr_complex.h.

238 { i = val; }
gmp_float i
Definition: mpr_complex.h:181

◆ isZero()

bool gmp_complex::isZero ( )
inline

Definition at line 241 of file mpr_complex.h.

241 { return (r.isZero() && i.isZero()); }
gmp_float i
Definition: mpr_complex.h:181
bool isZero() const
Definition: mpr_complex.cc:254
gmp_float r
Definition: mpr_complex.h:181

◆ neg()

gmp_complex & gmp_complex::neg ( )

Definition at line 662 of file mpr_complex.cc.

663 {
664  i.neg();
665  r.neg();
666  return *this;
667 }
gmp_float & neg()
Definition: mpr_complex.h:100
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ operator*=()

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

Definition at line 655 of file mpr_complex.cc.

656 {
657  gmp_float f = r * b.r - i * b.i;
658  i = r * b.i + i * b.r;
659  r = f;
660  return *this;
661 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
FILE * f
Definition: checklibs.c:9
const poly b
Definition: syzextra.cc:213

◆ operator+=()

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

Definition at line 643 of file mpr_complex.cc.

644 {
645  r+=b.r;
646  i+=b.i;
647  return *this;
648 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
const poly b
Definition: syzextra.cc:213

◆ operator-=()

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

Definition at line 649 of file mpr_complex.cc.

650 {
651  r-=b.r;
652  i-=b.i;
653  return *this;
654 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
const poly b
Definition: syzextra.cc:213

◆ operator/=()

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

Definition at line 668 of file mpr_complex.cc.

669 {
670  gmp_float d = b.r*b.r + b.i*b.i;
671  r = (r * b.r + i * b.i) / d;
672  i = (i * b.r - r * b.i) / d;
673  return *this;
674 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
const poly b
Definition: syzextra.cc:213

◆ operator=() [1/2]

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

Definition at line 288 of file mpr_complex.h.

289 {
290  r= a.r;
291  i= a.i;
292  return *this;
293 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ operator=() [2/2]

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

Definition at line 296 of file mpr_complex.h.

297 {
298  r= f;
299  i= (long int)0;
300  return *this;
301 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
FILE * f
Definition: checklibs.c:9

◆ real() [1/2]

gmp_float gmp_complex::real ( ) const
inline

Definition at line 234 of file mpr_complex.h.

234 { return r; }
gmp_float r
Definition: mpr_complex.h:181

◆ real() [2/2]

void gmp_complex::real ( gmp_float  val)
inline

Definition at line 237 of file mpr_complex.h.

237 { r = val; }
gmp_float r
Definition: mpr_complex.h:181

◆ SmallToZero()

void gmp_complex::SmallToZero ( )

Definition at line 786 of file mpr_complex.cc.

787 {
788  gmp_float ar=this->real();
789  gmp_float ai=this->imag();
790  if (ar.isZero() || ai.isZero()) return;
791  mpf_abs(*ar._mpfp(), *ar._mpfp());
792  mpf_abs(*ai._mpfp(), *ai._mpfp());
793  mpf_set_prec(*ar._mpfp(), 32);
794  mpf_set_prec(*ai._mpfp(), 32);
795  if (ar > ai)
796  {
797  mpf_div(*ai._mpfp(), *ai._mpfp(), *ar._mpfp());
798  if (ai < *gmpRel) this->imag(0.0);
799  }
800  else
801  {
802  mpf_div(*ar._mpfp(), *ar._mpfp(), *ai._mpfp());
803  if (ar < *gmpRel) this->real(0.0);
804  }
805 }
mpf_t * _mpfp()
Definition: mpr_complex.h:134
gmp_float real() const
Definition: mpr_complex.h:234
bool isZero() const
Definition: mpr_complex.cc:254
static gmp_float * gmpRel
Definition: mpr_complex.cc:46
gmp_float imag() const
Definition: mpr_complex.h:235

Friends And Related Function Documentation

◆ operator* [1/2]

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

Definition at line 629 of file mpr_complex.cc.

630 {
631  return gmp_complex( a.r * b.r - a.i * b.i,
632  a.r * b.i + a.i * b.r);
633 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator* [2/2]

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

Definition at line 255 of file mpr_complex.h.

256 {
257  return gmp_complex( a.r * b_d, a.i * b_d );
258 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator+ [1/2]

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

Definition at line 621 of file mpr_complex.cc.

622 {
623  return gmp_complex( a.r + b.r, a.i + b.i );
624 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator+ [2/2]

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

Definition at line 247 of file mpr_complex.h.

248 {
249  return gmp_complex( a.r + b_d, a.i );
250 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator- [1/2]

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

Definition at line 625 of file mpr_complex.cc.

626 {
627  return gmp_complex( a.r - b.r, a.i - b.i );
628 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator- [2/2]

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

Definition at line 251 of file mpr_complex.h.

252 {
253  return gmp_complex( a.r - b_d, a.i );
254 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator/ [1/2]

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

Definition at line 634 of file mpr_complex.cc.

635 {
636  gmp_float d = b.r*b.r + b.i*b.i;
637  return gmp_complex( (a.r * b.r + a.i * b.i) / d,
638  (a.i * b.r - a.r * b.i) / d);
639 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator/ [2/2]

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

Definition at line 259 of file mpr_complex.h.

260 {
261  return gmp_complex( a.r / b_d, a.i / b_d );
262 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)
Definition: mpr_complex.h:184

◆ operator<

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

Definition at line 273 of file mpr_complex.h.

274 {
275  return ( a.real() < b.real() );
276 }
gmp_float real() const
Definition: mpr_complex.h:234

◆ operator<=

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

Definition at line 281 of file mpr_complex.h.

282 {
283  return ( a.real() <= b.real() );
284 }
gmp_float real() const
Definition: mpr_complex.h:234

◆ operator==

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

Definition at line 265 of file mpr_complex.h.

266 {
267  return ( b.real() == a.real() ) && ( b.imag() == a.imag() );
268 }
gmp_float real() const
Definition: mpr_complex.h:234
gmp_float imag() const
Definition: mpr_complex.h:235

◆ operator>

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

Definition at line 269 of file mpr_complex.h.

270 {
271  return ( a.real() > b.real() );
272 }
gmp_float real() const
Definition: mpr_complex.h:234

◆ operator>=

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

Definition at line 277 of file mpr_complex.h.

278 {
279  return ( a.real() >= b.real() );
280 }
gmp_float real() const
Definition: mpr_complex.h:234

Field Documentation

◆ i

gmp_float gmp_complex::i
private

Definition at line 181 of file mpr_complex.h.

◆ r

gmp_float gmp_complex::r
private

Definition at line 181 of file mpr_complex.h.


The documentation for this class was generated from the following files: