My Project
Loading...
Searching...
No Matches
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_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_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 }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ~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; }

◆ imag() [2/2]

void gmp_complex::imag ( gmp_float  val)
inline

Definition at line 238 of file mpr_complex.h.

238{ i = val; }

◆ isZero()

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:252

◆ neg()

gmp_complex & gmp_complex::neg ( )

Definition at line 660 of file mpr_complex.cc.

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

◆ operator*=()

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

Definition at line 653 of file mpr_complex.cc.

654{
655 gmp_float f = r * b.r - i * b.i;
656 i = r * b.i + i * b.r;
657 r = f;
658 return *this;
659}
CanonicalForm b
Definition: cfModGcd.cc:4103
FILE * f
Definition: checklibs.c:9

◆ operator+=()

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

Definition at line 641 of file mpr_complex.cc.

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

◆ operator-=()

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

Definition at line 647 of file mpr_complex.cc.

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

◆ operator/=()

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

Definition at line 666 of file mpr_complex.cc.

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

◆ 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}

◆ 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}

◆ real() [1/2]

gmp_float gmp_complex::real ( ) const
inline

Definition at line 234 of file mpr_complex.h.

234{ return r; }

◆ real() [2/2]

void gmp_complex::real ( gmp_float  val)
inline

Definition at line 237 of file mpr_complex.h.

237{ r = val; }

◆ SmallToZero()

void gmp_complex::SmallToZero ( )

Definition at line 784 of file mpr_complex.cc.

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

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.

628{
629 return gmp_complex( a.r * b.r - a.i * b.i,
630 a.r * b.i + a.i * b.r);
631}
gmp_complex numbers based on
Definition: mpr_complex.h:179

◆ 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}

◆ 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}

◆ 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}

◆ operator- [1/2]

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

Definition at line 623 of file mpr_complex.cc.

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

◆ 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}

◆ operator/ [1/2]

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

Definition at line 632 of file mpr_complex.cc.

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

◆ 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}

◆ 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}

◆ 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}

◆ 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}

◆ 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}

◆ 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}

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: