My Project  debian-1:4.1.2-p1+ds-2
ftmpl_factor.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 #ifndef INCL_FACTOR_H
4 #define INCL_FACTOR_H
5 
6 #ifndef NOSTREAMIO
7 #ifdef HAVE_IOSTREAM
8 #include <iostream>
9 #define OSTREAM std::ostream
10 #elif defined(HAVE_IOSTREAM_H)
11 #include <iostream.h>
12 #define OSTREAM ostream
13 #endif
14 #endif /* NOSTREAMIO */
15 
16 
17 template <class T>
18 class Factor {
19 private:
21  int _exp;
22 public:
23  Factor() : _factor(1), _exp(0) {}
24  Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {}
25  Factor( const T & f, int e ) : _factor(f), _exp(e) {}
26  Factor( const T & f ) : _factor(f), _exp(1) {}
27  ~Factor() {}
28  Factor<T>& operator= ( const Factor<T>& );
29  Factor<T>& operator= ( const T& );
30  T factor() const { return _factor; }
31  int exp() const { return _exp; }
32  T value() const { return power( _factor, _exp ); }
33  Factor<T>& operator+= ( int i ) { _exp += i; return *this; }
34  Factor<T>& operator*= ( int i ) { _exp *= i; return *this; }
35  Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; }
36 #ifndef NOSTREAMIO
37  void print ( OSTREAM& ) const;
38 #endif /* NOSTREAMIO */
39 };
40 
41 template <class T> int
42 operator== ( const Factor<T>&, const Factor<T>& );
43 
44 #ifndef NOSTREAMIO
45 template <class T>
46 OSTREAM& operator<< ( OSTREAM & os, const Factor<T> & f );
47 #endif /* NOSTREAMIO */
48 
49 #endif /* ! INCL_FACTOR_H */
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
int i
Definition: cfEzgcd.cc:125
FILE * f
Definition: checklibs.c:9
Factor< T > & operator*=(int i)
Definition: ftmpl_factor.h:34
Factor< T > & operator=(const Factor< T > &)
Definition: ftmpl_factor.cc:6
void print(OSTREAM &) const
Definition: ftmpl_factor.cc:31
Factor(const Factor< T > &f)
Definition: ftmpl_factor.h:24
int exp() const
Definition: ftmpl_factor.h:31
T value() const
Definition: ftmpl_factor.h:32
T factor() const
Definition: ftmpl_factor.h:30
Factor(const T &f)
Definition: ftmpl_factor.h:26
Factor< T > & operator+=(int i)
Definition: ftmpl_factor.h:33
Factor(const T &f, int e)
Definition: ftmpl_factor.h:25
int _exp
Definition: ftmpl_factor.h:21
int operator==(const Factor< T > &, const Factor< T > &)
Definition: ftmpl_factor.cc:24
OSTREAM & operator<<(OSTREAM &os, const Factor< T > &f)
Definition: ftmpl_factor.cc:40
#define OSTREAM
Definition: ftmpl_factor.h:9
STATIC_VAR jList * T
Definition: janet.cc:30