My Project
Loading...
Searching...
No Matches
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 180 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 186 of file mpr_complex.h.

187 {
188 r= re;
189 i= im;
190 }
gmp_float i
gmp_float r

◆ gmp_complex() [2/4]

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

Definition at line 191 of file mpr_complex.h.

192 {
193 r= re;
194 i= im;
195 }

◆ gmp_complex() [3/4]

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

Definition at line 196 of file mpr_complex.h.

197 {
198 r= re;
199 i= im;
200 }

◆ gmp_complex() [4/4]

gmp_complex::gmp_complex ( const gmp_complex & v)
inline

Definition at line 201 of file mpr_complex.h.

202 {
203 r= v.r;
204 i= v.i;
205 }
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39

◆ ~gmp_complex()

gmp_complex::~gmp_complex ( )
inline

Definition at line 206 of file mpr_complex.h.

206{}

Member Function Documentation

◆ imag() [1/2]

gmp_float gmp_complex::imag ( ) const
inline

Definition at line 237 of file mpr_complex.h.

237{ return i; }

◆ imag() [2/2]

void gmp_complex::imag ( gmp_float val)
inline

Definition at line 240 of file mpr_complex.h.

240{ i = val; }

◆ isZero()

bool gmp_complex::isZero ( )
inline

Definition at line 243 of file mpr_complex.h.

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

◆ neg()

gmp_complex & gmp_complex::neg ( )

Definition at line 652 of file mpr_complex.cc.

653{
654 i.neg();
655 r.neg();
656 return *this;
657}

◆ operator*=()

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

Definition at line 645 of file mpr_complex.cc.

646{
647 gmp_float f = r * b.r - i * b.i;
648 i = r * b.i + i * b.r;
649 r = f;
650 return *this;
651}
CanonicalForm b
Definition cfModGcd.cc:4111
FILE * f
Definition checklibs.c:9

◆ operator+=()

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

Definition at line 633 of file mpr_complex.cc.

634{
635 r+=b.r;
636 i+=b.i;
637 return *this;
638}

◆ operator-=()

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

Definition at line 639 of file mpr_complex.cc.

640{
641 r-=b.r;
642 i-=b.i;
643 return *this;
644}

◆ operator/=()

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

Definition at line 658 of file mpr_complex.cc.

659{
660 gmp_float d = b.r*b.r + b.i*b.i;
661 r = (r * b.r + i * b.i) / d;
662 i = (i * b.r - r * b.i) / d;
663 return *this;
664}

◆ operator=() [1/2]

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

Definition at line 290 of file mpr_complex.h.

291{
292 r= a.r;
293 i= a.i;
294 return *this;
295}

◆ operator=() [2/2]

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

Definition at line 298 of file mpr_complex.h.

299{
300 r= f;
301 i= (long int)0;
302 return *this;
303}

◆ real() [1/2]

gmp_float gmp_complex::real ( ) const
inline

Definition at line 236 of file mpr_complex.h.

236{ return r; }

◆ real() [2/2]

void gmp_complex::real ( gmp_float val)
inline

Definition at line 239 of file mpr_complex.h.

239{ r = val; }

◆ SmallToZero()

void gmp_complex::SmallToZero ( )

Definition at line 776 of file mpr_complex.cc.

777{
778 gmp_float ar=this->real();
779 gmp_float ai=this->imag();
780 if (ar.isZero() || ai.isZero()) return;
781 mpf_abs(*ar._mpfp(), *ar._mpfp());
782 mpf_abs(*ai._mpfp(), *ai._mpfp());
783 mpf_set_prec(*ar._mpfp(), 32);
784 mpf_set_prec(*ai._mpfp(), 32);
785 if (ar > ai)
786 {
787 mpf_div(*ai._mpfp(), *ai._mpfp(), *ar._mpfp());
788 if (ai < *gmpRel) this->imag(0.0);
789 }
790 else
791 {
792 mpf_div(*ar._mpfp(), *ar._mpfp(), *ai._mpfp());
793 if (ar < *gmpRel) this->real(0.0);
794 }
795}
gmp_float imag() const
gmp_float real() const
mpf_t * _mpfp()
bool isZero() const
STATIC_VAR gmp_float * gmpRel

Friends And Related Symbol Documentation

◆ operator* [1/2]

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

Definition at line 619 of file mpr_complex.cc.

620{
621 return gmp_complex( a.r * b.r - a.i * b.i,
622 a.r * b.i + a.i * b.r);
623}
gmp_complex(const gmp_float re=0.0, const gmp_float im=0.0)

◆ operator* [2/2]

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

Definition at line 257 of file mpr_complex.h.

258{
259 return gmp_complex( a.r * b_d, a.i * b_d );
260}

◆ operator+ [1/2]

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

Definition at line 611 of file mpr_complex.cc.

612{
613 return gmp_complex( a.r + b.r, a.i + b.i );
614}

◆ operator+ [2/2]

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

Definition at line 249 of file mpr_complex.h.

250{
251 return gmp_complex( a.r + b_d, a.i );
252}

◆ operator- [1/2]

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

Definition at line 615 of file mpr_complex.cc.

616{
617 return gmp_complex( a.r - b.r, a.i - b.i );
618}

◆ operator- [2/2]

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

Definition at line 253 of file mpr_complex.h.

254{
255 return gmp_complex( a.r - b_d, a.i );
256}

◆ operator/ [1/2]

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

Definition at line 624 of file mpr_complex.cc.

625{
626 gmp_float d = b.r*b.r + b.i*b.i;
627 return gmp_complex( (a.r * b.r + a.i * b.i) / d,
628 (a.i * b.r - a.r * b.i) / d);
629}

◆ operator/ [2/2]

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

Definition at line 261 of file mpr_complex.h.

262{
263 return gmp_complex( a.r / b_d, a.i / b_d );
264}

◆ operator<

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

Definition at line 275 of file mpr_complex.h.

276{
277 return ( a.real() < b.real() );
278}

◆ operator<=

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

Definition at line 283 of file mpr_complex.h.

284{
285 return ( a.real() <= b.real() );
286}

◆ operator==

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

Definition at line 267 of file mpr_complex.h.

268{
269 return ( b.real() == a.real() ) && ( b.imag() == a.imag() );
270}

◆ operator>

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

Definition at line 271 of file mpr_complex.h.

272{
273 return ( a.real() > b.real() );
274}

◆ operator>=

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

Definition at line 279 of file mpr_complex.h.

280{
281 return ( a.real() >= b.real() );
282}

Field Documentation

◆ i

gmp_float gmp_complex::i
private

Definition at line 183 of file mpr_complex.h.

◆ r

gmp_float gmp_complex::r
private

Definition at line 183 of file mpr_complex.h.


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