GiNaCRA  0.6.4
GiNaCRA::RealAlgebraicNumberIR Class Reference

An implementation of an real algebraic number providing methods to add, multiply or evaluate their sign on polynomials. More...

#include <RealAlgebraicNumberIR.h>

Inheritance diagram for GiNaCRA::RealAlgebraicNumberIR:
Collaboration diagram for GiNaCRA::RealAlgebraicNumberIR:

Public Member Functions

 RealAlgebraicNumberIR (const RationalUnivariatePolynomial &p, const OpenInterval &i, const list< RationalUnivariatePolynomial > &s=list< RationalUnivariatePolynomial >(), const bool normalize=true, const bool isRoot=true) throw ( invalid_argument )
 Constructs a real algebraic number in interval representation (p, l, r) with a normalized interval w.r.t.
 ~RealAlgebraicNumberIR ()
 Destructor.
RealAlgebraicNumberPtr clone () const
 Clone-"Constructor".
const RationalUnivariatePolynomial polynomial () const
 Selects the polynomial having this real algebraic number as one of its roots.
const OpenInterval interval () const
 Selects the open interval ]l, r[ containing the real algebraic number.
const list
< RationalUnivariatePolynomial
sturmSequence () const
 Returns a pre-computed standard Sturm sequence of the polynomial and its derivative.
const unsigned refinementCount () const
 Returns how often one of the refine methods was called before.
const RealAlgebraicNumberIRoperator= (const RealAlgebraicNumberIR &)
 This number gets all values of the other.
void normalizeInterval () throw ( invalid_argument )
 Normalizes the interval of an real algebraic number to not contain zero, in case the number is non-zero.
void refine (RealAlgebraicNumberSettings::RefinementStrategy strategy=RealAlgebraicNumberSettings::DEFAULT_REFINEMENTSTRATEGY)
 Refines the interval i of this real algebraic number yielding the interval j such that 2*(j.Right()-j.Left()) <= i.Right()-i.Left().
void refine (numeric eps)
 Refines the interval i of this real algebraic number yielding the interval j such that (j.Right()-j.Left()) <= eps.
bool refineAvoiding (numeric n)
 Refines the interval i of this real algebraic number yielding the interval j such that !j.meets(n).
GiNaC::sign sgn () const
 Returns sign (GiNaC::ZERO_SIGN, GiNaC::POSITIVE_SIGN, GiNaC::NEGATIVE_SIGN) of this real algebraic number.
GiNaC::sign sgn (const RationalUnivariatePolynomial &p) const
 Returns sign (GiNaC::ZERO_SIGN, GiNaC::POSITIVE_SIGN, GiNaC::NEGATIVE_SIGN) of the specified univariate polynomial at this real algebraic number.
const numeric approximateValue () const
 Computes a numeric value for this real algebraic number approximating it.
const numeric sampleValue () const
 Chooses a numeric value out of the isolating interval with the smallest numeric representation.
RealAlgebraicNumberIRadd (RealAlgebraicNumberIR &o) throw ( invalid_argument )
 Adds two real algebraic numbers and returns a reference to their sum.
RealAlgebraicNumberIRminus () const
 Returns the negative value.
RealAlgebraicNumberIRmul (RealAlgebraicNumberIR &o) throw ( invalid_argument )
 Multiplies two real algebraic numbers and returns a reference to their product.
RealAlgebraicNumberIRinverse () const throw ( invalid_argument )
 Returns the inverse.
RealAlgebraicNumberIRpow (int e) throw ( invalid_argument )
 Returns the power.
const bool isEqual (RealAlgebraicNumberIR &o)
 Compares two real algebraic numbers for equality.
const bool isLessWhileUnequal (RealAlgebraicNumberIR &o)
 Checks whether this number is less than the other while assuming that the two numbers are unequal.
const bool isLess (RealAlgebraicNumberIR &o)
 Compares two real algebraic numbers by less-than.
bool info (unsigned inf) const
const bool isRoot () const
void setIsRoot (bool isRoot)
 Set the flag marking whether the real algebraic number stems from a root computation or not.
bool isNumeric () const
 Returns true if an exact numeric representation was found during the refinements.
const numeric value () const
 Gives an exact numeric representation of this real algebraic number which could have been found during the refinement steps.

Static Public Member Functions

static RealAlgebraicNumberIRzero (const symbol &s)

Protected Member Functions

bool is_equal_same_type (const basic &other) const
void do_print (const print_context &c, unsigned level=0) const
ex evalf (int level=0) const
 Outputs the midpoint of the isolating interval after level additional refinements.
unsigned calchash () const

Protected Attributes

bool mIsRoot
 flag indicating whether this number represents a root of a polynomial or an intermediate point
bool mIsNumeric
 flag indicating whether this number is representable by a numeric
numeric mValue
 the exact numeric value of this number if available, otherwise mIsNumeric is false and mValue 0

Private Member Functions

 RealAlgebraicNumberIR (const symbol &s) throw ( invalid_argument )
 Private zero constructor.

Private Attributes

RationalUnivariatePolynomial mPolynomial
 polynomial of this interval representation
OpenInterval mInterval
 isolating interval of this interval representation
list
< RationalUnivariatePolynomial
mSturmSequence
 Standard Sturm sequence of the polynomial and its derivative.
unsigned mRefinementCount
 number of refinements executed to the isolating interval

Detailed Description

An implementation of an real algebraic number providing methods to add, multiply or evaluate their sign on polynomials.

Author:
Ulrich Loup
Since:
2010-07-28
Version:
2012-05-07
See also:
ISBN 0-387-94090-1 and ISBN-13: 978-3642069642

Definition at line 52 of file RealAlgebraicNumberIR.h.


Constructor & Destructor Documentation

GiNaCRA::RealAlgebraicNumberIR::RealAlgebraicNumberIR ( const RationalUnivariatePolynomial p,
const OpenInterval i,
const list< RationalUnivariatePolynomial > &  s = list<RationalUnivariatePolynomial>(),
const bool  normalize = true,
const bool  isRoot = true 
) throw ( invalid_argument )

Constructs a real algebraic number in interval representation (p, l, r) with a normalized interval w.r.t.

normalizeInterval. Constructs a real algebraic number in interval and order representation (p, l, r, o) with a normalized interval w.r.t. normalizeInterval.

  • p can be changed within the constructor, but is later constant.
  • i can be changed later by refine(), but is only normalized within the constructor in case not normalized before.
Parameters:
ppolynomial having the real algebraic number as one of its roots
iopen interval ]l, r[ containing the real algebraic number (should be normalized)
sstandard Sturm sequence
normalizeif set to false, the interval will not be normalized in the constructor (default is true)
isRoottrue marks this real algebraic number to stem from a root computation

Definition at line 75 of file RealAlgebraicNumberIR.cpp.

Referenced by clone(), inverse(), minus(), and zero().

GiNaCRA::RealAlgebraicNumberIR::RealAlgebraicNumberIR ( const symbol &  s) throw ( invalid_argument ) [private]

Private zero constructor.

Parameters:
smain symbol of the polynomial belonging to the real algebraic number

Definition at line 65 of file RealAlgebraicNumberIR.cpp.


Member Function Documentation

const numeric GiNaCRA::RealAlgebraicNumberIR::approximateValue ( ) const [inline, virtual]

Computes a numeric value for this real algebraic number approximating it.

This is also the outcome of ex::evalf().

Runtime complexity:
constant
Returns:
a numeric value for this real algebraic number approximating it

Reimplemented from GiNaCRA::RealAlgebraicNumber.

Definition at line 202 of file RealAlgebraicNumberIR.h.

References GiNaCRA::OpenInterval::midpoint(), and mInterval.

Referenced by evalf().

unsigned GiNaCRA::RealAlgebraicNumberIR::calchash ( ) const [protected]

Definition at line 169 of file RealAlgebraicNumberIR.cpp.

References mPolynomial.

Clone-"Constructor".

Reimplemented from GiNaCRA::RealAlgebraicNumber.

Definition at line 113 of file RealAlgebraicNumberIR.cpp.

References RealAlgebraicNumberIR().

void GiNaCRA::RealAlgebraicNumberIR::do_print ( const print_context &  c,
unsigned  level = 0 
) const [protected]
ex GiNaCRA::RealAlgebraicNumberIR::evalf ( int  level = 0) const [protected]

Outputs the midpoint of the isolating interval after level additional refinements.

Note that the refinements are not performed on this object but on a copy since this method does not mute this object.

Parameters:
levelnumber of additional refinements
Returns:
midpoint of the isolating interval after level additional refinements

Definition at line 157 of file RealAlgebraicNumberIR.cpp.

References approximateValue(), GiNaCRA::OpenInterval::midpoint(), mInterval, and refine().

bool GiNaCRA::RealAlgebraicNumberIR::info ( unsigned  inf) const

Definition at line 174 of file RealAlgebraicNumberIR.cpp.

Selects the open interval ]l, r[ containing the real algebraic number.

Returns:
open interval ]l, r[ containing the real algebraic number

Definition at line 120 of file RealAlgebraicNumberIR.h.

References mInterval.

Referenced by add(), is_equal_same_type(), isEqual(), mul(), GiNaCRA::operator*(), GiNaCRA::operator+(), and GiNaCRA::operator-().

Compares two real algebraic numbers for equality.

Note that both numbers could be muted by means of refinement!

Parameters:
o
Returns:
true in case the other real algebraic number is equals to this one

Definition at line 496 of file RealAlgebraicNumberIR.cpp.

References add(), interval(), GiNaCRA::OpenInterval::isZero(), GiNaCRA::OpenInterval::left(), mInterval, minus(), GiNaCRA::RealAlgebraicNumber::mIsNumeric, GiNaCRA::RealAlgebraicNumber::mValue, and GiNaCRA::OpenInterval::right().

Referenced by isLess(), GiNaCRA::operator!=(), GiNaCRA::operator<=(), GiNaCRA::operator==(), and GiNaCRA::operator>().

Compares two real algebraic numbers by less-than.

Note that both numbers could be muted by means of refinement!

Parameters:
oreference to the other real algebraic number.
Returns:
true in case the other real algebraic number is strictly less than this one

Definition at line 532 of file RealAlgebraicNumberIR.cpp.

References isEqual(), and isLessWhileUnequal().

Referenced by GiNaCRA::operator<(), and GiNaCRA::operator>=().

Checks whether this number is less than the other while assuming that the two numbers are unequal.

Note that both numbers could be muted by means of refinement!

Parameters:
o
Returns:
true in case the other real algebraic number is less to this one if the two number do not equal (otherwise there might be an infinite refinement loop)

Check whether -----]--------[---------------- --------------]--------[------- .

Check whether --------------]--------[------- -----]--------[---------------- .

Definition at line 507 of file RealAlgebraicNumberIR.cpp.

References GiNaCRA::OpenInterval::left(), mInterval, refine(), and GiNaCRA::OpenInterval::right().

Referenced by isLess(), GiNaCRA::operator<=(), and GiNaCRA::operator>().

bool GiNaCRA::RealAlgebraicNumber::isNumeric ( ) const [inline, inherited]

Returns true if an exact numeric representation was found during the refinements.

Returns:
true if an exact numeric representation was found during the refinements, false otherwise.

Definition at line 96 of file RealAlgebraicNumber.h.

References GiNaCRA::RealAlgebraicNumber::mIsNumeric.

Referenced by GiNaCRA::binaryOperator().

const bool GiNaCRA::RealAlgebraicNumber::isRoot ( ) const [inline, inherited]
Returns:
the flag marking whether the real algebraic number stems from a root computation or not

Definition at line 78 of file RealAlgebraicNumber.h.

References GiNaCRA::RealAlgebraicNumber::mIsRoot.

Referenced by GiNaCRA::RealAlgebraicNumber::setIsRoot().

Selects the polynomial having this real algebraic number as one of its roots.

Returns:
polynomial having the number as one of its roots

Definition at line 111 of file RealAlgebraicNumberIR.h.

References mPolynomial.

Referenced by GiNaCRA::operator*(), GiNaCRA::operator+(), and GiNaCRA::operator-().

RealAlgebraicNumberIR & GiNaCRA::RealAlgebraicNumberIR::pow ( int  e) throw ( invalid_argument )

Returns the power.

Parameters:
e
Returns:
inverse value

Definition at line 465 of file RealAlgebraicNumberIR.cpp.

References mul().

Referenced by GiNaCRA::operator^().

void GiNaCRA::RealAlgebraicNumberIR::refine ( numeric  eps) [inline]

Refines the interval i of this real algebraic number yielding the interval j such that (j.Right()-j.Left()) <= eps.

Parameters:
eps

Definition at line 171 of file RealAlgebraicNumberIR.h.

References GiNaCRA::OpenInterval::left(), mInterval, refine(), and GiNaCRA::OpenInterval::right().

const unsigned GiNaCRA::RealAlgebraicNumberIR::refinementCount ( ) const [inline]

Returns how often one of the refine methods was called before.

Returns:
number of refinement steps executed on this real algebraic number

Definition at line 137 of file RealAlgebraicNumberIR.h.

References mRefinementCount.

const numeric GiNaCRA::RealAlgebraicNumberIR::sampleValue ( ) const [inline]

Chooses a numeric value out of the isolating interval with the smallest numeric representation.

Runtime complexity:
constant
Returns:
a numeric value for this real algebraic representing a good sample

Definition at line 211 of file RealAlgebraicNumberIR.h.

References mInterval, and GiNaCRA::OpenInterval::sample().

void GiNaCRA::RealAlgebraicNumber::setIsRoot ( bool  isRoot) [inline, inherited]

Set the flag marking whether the real algebraic number stems from a root computation or not.

Parameters:
isRoot

Definition at line 87 of file RealAlgebraicNumber.h.

References GiNaCRA::RealAlgebraicNumber::isRoot(), and GiNaCRA::RealAlgebraicNumber::mIsRoot.

Returns sign (GiNaC::ZERO_SIGN, GiNaC::POSITIVE_SIGN, GiNaC::NEGATIVE_SIGN) of this real algebraic number.

Returns:
sign of this real algebraic number.

Reimplemented from GiNaCRA::RealAlgebraicNumber.

Definition at line 367 of file RealAlgebraicNumberIR.cpp.

References GiNaCRA::OpenInterval::isZero(), GiNaCRA::OpenInterval::left(), mInterval, GiNaC::NEGATIVE_SIGN, GiNaC::POSITIVE_SIGN, and GiNaC::ZERO_SIGN.

Returns a pre-computed standard Sturm sequence of the polynomial and its derivative.

Returns:
standard Sturm sequence of the polynomial and its derivative.

Definition at line 129 of file RealAlgebraicNumberIR.h.

References mSturmSequence.

const numeric GiNaCRA::RealAlgebraicNumber::value ( ) const [inline, inherited]

Gives an exact numeric representation of this real algebraic number which could have been found during the refinement steps.

The method returns 0 if the value was never set during refinement.

Returns:
an exact numeric representation of this real algebraic number which could have been found during the refinement steps

Definition at line 105 of file RealAlgebraicNumber.h.

References GiNaCRA::RealAlgebraicNumber::mValue.

Referenced by GiNaCRA::binaryOperator(), and GiNaCRA::RealAlgebraicNumberFactory::less().

Parameters:
sthe main variable of the underlying polynomial
Returns:
the RealAlgebraicNumberIR representation for 0

Definition at line 543 of file RealAlgebraicNumberIR.cpp.

References RealAlgebraicNumberIR().

Referenced by GiNaCRA::operator*().


Field Documentation

bool GiNaCRA::RealAlgebraicNumber::mIsNumeric [protected, inherited]

flag indicating whether this number is representable by a numeric

Definition at line 158 of file RealAlgebraicNumber.h.

Referenced by do_print(), is_equal_same_type(), isEqual(), GiNaCRA::RealAlgebraicNumber::isNumeric(), operator=(), refine(), and refineAvoiding().

bool GiNaCRA::RealAlgebraicNumber::mIsRoot [protected, inherited]

flag indicating whether this number represents a root of a polynomial or an intermediate point

Definition at line 156 of file RealAlgebraicNumber.h.

Referenced by GiNaCRA::RealAlgebraicNumberNR::do_print(), do_print(), GiNaCRA::RealAlgebraicNumber::isRoot(), GiNaCRA::RealAlgebraicNumber::operator=(), operator=(), and GiNaCRA::RealAlgebraicNumber::setIsRoot().

number of refinements executed to the isolating interval

Definition at line 321 of file RealAlgebraicNumberIR.h.

Referenced by operator=(), refine(), refineAvoiding(), and refinementCount().

Standard Sturm sequence of the polynomial and its derivative.

Definition at line 319 of file RealAlgebraicNumberIR.h.

Referenced by normalizeInterval(), operator=(), refine(), refineAvoiding(), and sturmSequence().

numeric GiNaCRA::RealAlgebraicNumber::mValue [protected, inherited]

the exact numeric value of this number if available, otherwise mIsNumeric is false and mValue 0

Definition at line 160 of file RealAlgebraicNumber.h.

Referenced by do_print(), is_equal_same_type(), isEqual(), operator=(), GiNaCRA::RealAlgebraicNumberNR::RealAlgebraicNumberNR(), refine(), refineAvoiding(), and GiNaCRA::RealAlgebraicNumber::value().


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