source: git/Singular/GMPrat.h @ fdc537

spielwiese
Last change on this file since fdc537 was 7885020, checked in by Hans Schönemann <hannes@…>, 25 years ago
* hannes: integrated "spectrum" by Stefan Endrass, inactive by default (Makefile.in claptmpl.cc feResource.cc iparith.cc mod2.h.in tok.h GMPrat.h GMPrat.cc kmatrix.h multicnt.h multicnt.cc npolygon.h npolygon.cc semic.h semic.cc spectrum.h spectrum.cc splist.h splist.cc) git-svn-id: file:///usr/local/Singular/svn/trunk@3423 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.3 KB
Line 
1// ----------------------------------------------------------------------------
2//  GMPrat.h
3//  begin of file
4//  originally written by Gerd Sussner, sussner@mi.uni-erlangen.de
5//  copied by Stephan Endrass, endrass@mathematik.uni-mainz.de
6//  23.7.99
7// ----------------------------------------------------------------------------
8
9#ifndef  GMPRAT_H
10#define  GMPRAT_H
11
12#include "gmp.h"
13
14class Rational
15{
16    struct rep
17    {
18        mpq_t rat;
19        int   n;
20        rep() { n=1; }
21    };
22
23    rep             *p;
24    static Rational save;
25
26    void disconnect();
27
28    public:
29
30    Rational( );
31    Rational( long int );
32    Rational( unsigned long int );
33    Rational( int );
34    Rational( unsigned int );
35    Rational( short int );
36    Rational( unsigned short int );
37    Rational( char );
38    Rational( unsigned char );
39    Rational( double );
40    Rational( float );
41    Rational( char* );
42    Rational( const Rational& );
43    Rational( long int,unsigned long int );
44    Rational( unsigned long int,unsigned long int );
45    Rational( int, unsigned int );
46    Rational( unsigned int,unsigned int );
47    Rational( short int,unsigned short int );
48    Rational( unsigned short int,unsigned short int );
49    Rational( char,unsigned char );
50    Rational( unsigned char,unsigned char );
51    Rational( const Rational&,const Rational& );
52    Rational( long int,long int );
53    Rational( int,int );
54    Rational( short int,short int );
55    Rational( char,char );
56    Rational( char*,char* );
57    ~Rational( );
58
59    Rational& operator = ( long int );
60    Rational& operator = ( unsigned long int );
61    Rational& operator = ( int );
62    Rational& operator = ( unsigned int );
63    Rational& operator = ( short int );
64    Rational& operator = ( unsigned short int );
65    Rational& operator = ( char );
66    Rational& operator = ( unsigned char );
67    Rational& operator = ( double );
68    Rational& operator = ( float );
69    Rational& operator = ( char *s );
70    Rational& operator = ( const Rational& );
71
72    unsigned int length( ) const;
73    Rational get_num( );
74    Rational get_den( );
75    int      get_num_si( );
76    int      get_den_si( );
77    operator bool( );
78    operator long int( );
79    operator unsigned long int( );
80    operator int( );
81    operator unsigned int( );
82    operator short int( );
83    operator unsigned short int( );
84    operator char( );
85    operator unsigned char( );
86    operator double( );
87    operator float( );
88
89    Rational  operator - ( );
90    Rational  operator ~ ( );
91    Rational& operator += ( const Rational& );
92    Rational& operator -= ( const Rational& );
93    Rational& operator *= ( const Rational& );
94    Rational& operator /= ( const Rational& );
95    Rational& operator ++ ( );
96    Rational  operator ++ ( int );
97    Rational& operator -- ( );
98    Rational  operator -- ( int );
99
100    friend Rational operator - ( const Rational& );
101
102    friend bool operator <  ( const Rational&,const Rational& );
103    friend bool operator <= ( const Rational&,const Rational& );
104    friend bool operator >  ( const Rational&,const Rational& );
105    friend bool operator >= ( const Rational&,const Rational& );
106    friend bool operator == ( const Rational&,const Rational& );
107    friend bool operator != ( const Rational&,const Rational& );
108
109    #ifdef GMPRAT_PRINT
110    friend ostream& operator<<( ostream&,const Rational& );
111    #endif
112
113    friend int      sgn ( const Rational& );
114    friend Rational abs ( const Rational& );
115    friend Rational sqrt( const Rational& );
116    friend Rational pow ( const Rational&,int );
117
118    double   complexity( ) const;
119
120    friend Rational gcd ( const Rational&, const Rational& );
121    friend Rational lcm ( const Rational&, const Rational& );
122    friend Rational gcd ( Rational*, int );
123    friend Rational lcm ( Rational*, int );
124};
125
126Rational operator + ( const Rational&, const Rational& );
127Rational operator - ( const Rational&, const Rational& );
128Rational operator * ( const Rational&, const Rational& );
129Rational operator / ( const Rational&, const Rational& );
130
131Rational exp( const Rational& );
132Rational sin( const Rational& );
133Rational cos( const Rational& );
134Rational tan( const Rational& );
135
136#endif /* GMPRAT_H */
137
138// ----------------------------------------------------------------------------
139//  GMPrat.h
140//  end of file
141// ----------------------------------------------------------------------------
142
Note: See TracBrowser for help on using the repository browser.