GiNaCRA
0.6.4
|
00001 /* 00002 * GiNaCRA - GiNaC Real Algebra package 00003 * Copyright (C) 2010-2012 Ulrich Loup, Joachim Redies, Sebastian Junges 00004 * 00005 * This file is part of GiNaCRA. 00006 * 00007 * GiNaCRA is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * GiNaCRA is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GiNaCRA. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 */ 00021 00022 00023 #ifndef GINACRA_REALALGEBRAICNUMBER_H 00024 #define GINACRA_REALALGEBRAICNUMBER_H 00025 00026 #include <ginac/ginac.h> 00027 #include <tr1/memory> 00028 00029 #include "RationalUnivariatePolynomial.h" 00030 #include "constants.h" 00031 00032 namespace GiNaCRA 00033 { 00042 class RealAlgebraicNumber 00043 { 00044 public: 00045 00047 // Con- and destructors // 00049 00056 RealAlgebraicNumber( bool isRoot, bool isNumeric = false, const numeric& value = 0 ); 00057 00061 ~RealAlgebraicNumber(); 00062 00066 virtual std::tr1::shared_ptr<RealAlgebraicNumber> clone() const 00067 { 00068 return std::tr1::shared_ptr<RealAlgebraicNumber>( new RealAlgebraicNumber( *this )); 00069 } 00070 00072 // Selectors // 00074 00078 const bool isRoot() const 00079 { 00080 return mIsRoot; 00081 } 00082 00087 void setIsRoot( bool isRoot ) 00088 { 00089 mIsRoot = isRoot; 00090 } 00091 00096 bool isNumeric() const 00097 { 00098 return mIsNumeric; 00099 } 00100 00105 const numeric value() const 00106 { 00107 return mValue; 00108 } 00109 00111 // Operators // 00113 00114 // assignment operators 00115 00120 virtual const RealAlgebraicNumber& operator = ( const RealAlgebraicNumber& o ) 00121 { 00122 mIsRoot = o.mIsRoot; 00123 return *this; 00124 } 00125 00127 // Operations // 00129 00134 virtual GiNaC::sign sgn() const; 00135 00141 virtual GiNaC::sign sgn( const RationalUnivariatePolynomial& p ) const; 00142 00147 virtual const numeric approximateValue() const; 00148 00149 protected: 00150 00152 // Attributes // 00154 00156 bool mIsRoot; 00158 bool mIsNumeric; 00160 numeric mValue; 00161 }; 00162 00164 // TYPES // 00166 00168 typedef std::tr1::shared_ptr<RealAlgebraicNumber> RealAlgebraicNumberPtr; 00169 00171 struct RealAlgebraicNumberPtrHasher 00172 { 00173 size_t operator ()( RealAlgebraicNumberPtr p ) const 00174 { 00175 return (size_t)p.get(); 00176 } 00177 }; 00178 00179 } 00180 00181 #endif