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 // #include <factory/factoryconf.h>
7 
8 #ifndef NOSTREAMIO
9 #ifdef HAVE_IOSTREAM
10 #include <iostream>
11 #define OSTREAM std::ostream
12 #elif defined(HAVE_IOSTREAM_H)
13 #include <iostream.h>
14 #define OSTREAM ostream
15 #endif
16 #endif /* NOSTREAMIO */
17 
18 
19 template <class T>
20 class Factor {
21 private:
23  int _exp;
24 public:
25  Factor() : _factor(1), _exp(0) {}
26  Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {}
27  Factor( const T & f, int e ) : _factor(f), _exp(e) {}
28  Factor( const T & f ) : _factor(f), _exp(1) {}
29  ~Factor() {}
30  Factor<T>& operator= ( const Factor<T>& );
31  Factor<T>& operator= ( const T& );
32  T factor() const { return _factor; }
33  int exp() const { return _exp; }
34  T value() const { return power( _factor, _exp ); }
35  Factor<T>& operator+= ( int i ) { _exp += i; return *this; }
36  Factor<T>& operator*= ( int i ) { _exp *= i; return *this; }
37  Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; }
38 #ifndef NOSTREAMIO
39  void print ( OSTREAM& ) const;
40 #endif /* NOSTREAMIO */
41 };
42 
43 template <class T> int
44 operator== ( const Factor<T>&, const Factor<T>& );
45 
46 #ifndef NOSTREAMIO
47 template <class T>
48 OSTREAM& operator<< ( OSTREAM & os, const Factor<T> & f );
49 #endif /* NOSTREAMIO */
50 
51 #endif /* ! INCL_FACTOR_H */
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
int exp() const
Definition: ftmpl_factor.h:33
Factor(const T &f, int e)
Definition: ftmpl_factor.h:27
Factor< T > & operator+=(int i)
Definition: ftmpl_factor.h:35
#define OSTREAM
Definition: ftmpl_factor.h:11
Factor< T > & operator=(const Factor< T > &)
Definition: ftmpl_factor.cc:6
Factor(const Factor< T > &f)
Definition: ftmpl_factor.h:26
T factor() const
Definition: ftmpl_factor.h:32
void print(OSTREAM &) const
Definition: ftmpl_factor.cc:31
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
Factor< T > & operator*=(int i)
Definition: ftmpl_factor.h:36
int operator==(const Factor< T > &, const Factor< T > &)
Definition: ftmpl_factor.cc:24
static jList * T
Definition: janet.cc:37
Factor(const T &f)
Definition: ftmpl_factor.h:28
int _exp
Definition: ftmpl_factor.h:23
T value() const
Definition: ftmpl_factor.h:34