source: git/Singular/GMPrat.h @ f9aada

spielwiese
Last change on this file since f9aada was f9aada, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: simplified GMPrat git-svn-id: file:///usr/local/Singular/svn/trunk@5566 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.5 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( double );
36    Rational( float );
37    Rational( char* );
38    Rational( const Rational& );
39    Rational( long int,unsigned long int );
40    Rational( unsigned long int,unsigned long int );
41    Rational( int, unsigned int );
42    Rational( unsigned int,unsigned int );
43    Rational( const Rational&,const Rational& );
44    Rational( long int,long int );
45    Rational( int,int );
46    Rational( char*,char* );
47    ~Rational( );
48
49    Rational& operator = ( int );
50    Rational& operator = ( double );
51    Rational& operator = ( float );
52    Rational& operator = ( char *s );
53    Rational& operator = ( const Rational& );
54
55    unsigned int length( ) const;
56    Rational get_num( );
57    Rational get_den( );
58    int      get_num_si( );
59    int      get_den_si( );
60    operator bool( );
61    operator long int( );
62    operator unsigned long int( );
63    operator int( );
64    operator unsigned int( );
65    operator short int( );
66    operator unsigned short int( );
67    operator char( );
68    operator unsigned char( );
69    operator double( );
70    operator float( );
71
72    Rational  operator - ( );
73    Rational  operator ~ ( );
74    Rational& operator += ( const Rational& );
75    Rational& operator -= ( const Rational& );
76    Rational& operator *= ( const Rational& );
77    Rational& operator /= ( const Rational& );
78    Rational& operator ++ ( );
79    Rational  operator ++ ( int );
80    Rational& operator -- ( );
81    Rational  operator -- ( int );
82
83    friend Rational operator - ( const Rational& );
84
85    friend bool operator <  ( const Rational&,const Rational& );
86    friend bool operator <= ( const Rational&,const Rational& );
87    friend bool operator >  ( const Rational&,const Rational& );
88    friend bool operator >= ( const Rational&,const Rational& );
89    friend bool operator == ( const Rational&,const Rational& );
90    friend bool operator != ( const Rational&,const Rational& );
91
92    #ifdef GMPRAT_PRINT
93    friend ostream& operator<<( ostream&,const Rational& );
94    #endif
95
96    friend int      sgn ( const Rational& );
97    friend Rational abs ( const Rational& );
98    friend Rational pow ( const Rational&,int );
99
100    double   complexity( ) const;
101
102    friend Rational gcd ( const Rational&, const Rational& );
103    friend Rational lcm ( const Rational&, const Rational& );
104    friend Rational gcd ( Rational*, int );
105    friend Rational lcm ( Rational*, int );
106};
107
108Rational operator + ( const Rational&, const Rational& );
109Rational operator - ( const Rational&, const Rational& );
110Rational operator * ( const Rational&, const Rational& );
111Rational operator / ( const Rational&, const Rational& );
112
113#endif /* GMPRAT_H */
114
115// ----------------------------------------------------------------------------
116//  GMPrat.h
117//  end of file
118// ----------------------------------------------------------------------------
119
Note: See TracBrowser for help on using the repository browser.