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::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::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::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::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 ( )
inline

Definition at line 204 of file mpr_complex.h.

204 {}

Member Function Documentation

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
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
bool gmp_complex::isZero ( )
inline

Definition at line 241 of file mpr_complex.h.

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

Definition at line 673 of file mpr_complex.cc.

674 {
675  i.neg();
676  r.neg();
677  return *this;
678 }
gmp_float & neg()
Definition: mpr_complex.h:100
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
gmp_complex & gmp_complex::operator*= ( const gmp_complex a)

Definition at line 666 of file mpr_complex.cc.

667 {
668  gmp_float f = r * b.r - i * b.i;
669  i = r * b.i + i * b.r;
670  r = f;
671  return *this;
672 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
FILE * f
Definition: checklibs.c:7
const poly b
Definition: syzextra.cc:213
gmp_complex & gmp_complex::operator+= ( const gmp_complex a)

Definition at line 654 of file mpr_complex.cc.

655 {
656  r+=b.r;
657  i+=b.i;
658  return *this;
659 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
const poly b
Definition: syzextra.cc:213
gmp_complex & gmp_complex::operator-= ( const gmp_complex a)

Definition at line 660 of file mpr_complex.cc.

661 {
662  r-=b.r;
663  i-=b.i;
664  return *this;
665 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
const poly b
Definition: syzextra.cc:213
gmp_complex & gmp_complex::operator/= ( const gmp_complex a)

Definition at line 679 of file mpr_complex.cc.

680 {
681  gmp_float d = b.r*b.r + b.i*b.i;
682  r = (r * b.r + i * b.i) / d;
683  i = (i * b.r - r * b.i) / d;
684  return *this;
685 }
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181
const poly b
Definition: syzextra.cc:213
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
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:7
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
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
void gmp_complex::SmallToZero ( )

Definition at line 797 of file mpr_complex.cc.

798 {
799  gmp_float ar=this->real();
800  gmp_float ai=this->imag();
801  if (ar.isZero() || ai.isZero()) return;
802  mpf_abs(*ar._mpfp(), *ar._mpfp());
803  mpf_abs(*ai._mpfp(), *ai._mpfp());
804  mpf_set_prec(*ar._mpfp(), 32);
805  mpf_set_prec(*ai._mpfp(), 32);
806  if (ar > ai)
807  {
808  mpf_div(*ai._mpfp(), *ai._mpfp(), *ar._mpfp());
809  if (ai < *gmpRel) this->imag(0.0);
810  }
811  else
812  {
813  mpf_div(*ar._mpfp(), *ar._mpfp(), *ai._mpfp());
814  if (ar < *gmpRel) this->real(0.0);
815  }
816 }
bool isZero() const
Definition: mpr_complex.cc:254
mpf_t * _mpfp()
Definition: mpr_complex.h:134
gmp_float imag() const
Definition: mpr_complex.h:235
static gmp_float * gmpRel
Definition: mpr_complex.cc:46
gmp_float real() const
Definition: mpr_complex.h:234

Friends And Related Function Documentation

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

Definition at line 640 of file mpr_complex.cc.

641 {
642  return gmp_complex( a.r * b.r - a.i * b.i,
643  a.r * b.i + a.i * b.r);
644 }
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
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
gmp_complex operator+ ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 632 of file mpr_complex.cc.

633 {
634  return gmp_complex( a.r + b.r, a.i + b.i );
635 }
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
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
gmp_complex operator- ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 636 of file mpr_complex.cc.

637 {
638  return gmp_complex( a.r - b.r, a.i - b.i );
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
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
gmp_complex operator/ ( const gmp_complex a,
const gmp_complex b 
)
friend

Definition at line 645 of file mpr_complex.cc.

646 {
647  gmp_float d = b.r*b.r + b.i*b.i;
648  return gmp_complex( (a.r * b.r + a.i * b.i) / d,
649  (a.i * b.r - a.r * b.i) / d);
650 }
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
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
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
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
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 imag() const
Definition: mpr_complex.h:235
gmp_float real() const
Definition: mpr_complex.h:234
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
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

gmp_float gmp_complex::i
private

Definition at line 181 of file mpr_complex.h.

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: