spielwiese
Last change
on this file since b1dfaf was
b1dfaf,
checked in by Frank Seelisch <seelisch@…>, 13 years ago
|
patch from Kai (checked for problems under Windows OS: no problems)
git-svn-id: file:///usr/local/Singular/svn/trunk@13210 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[6ab5981] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[341696] | 2 | /* $Id$ */ |
---|
[684544] | 3 | |
---|
| 4 | #ifndef INCL_FACTOR_H |
---|
| 5 | #define INCL_FACTOR_H |
---|
| 6 | |
---|
[b1dfaf] | 7 | #include <factory/factoryconf.h> |
---|
[8c0163] | 8 | |
---|
[175e355] | 9 | #ifndef NOSTREAMIO |
---|
[1dc616] | 10 | #ifdef HAVE_IOSTREAM |
---|
| 11 | #include <iostream> |
---|
[181148] | 12 | #define OSTREAM std::ostream |
---|
[1dc616] | 13 | #elif defined(HAVE_IOSTREAM_H) |
---|
[684544] | 14 | #include <iostream.h> |
---|
[181148] | 15 | #define OSTREAM ostream |
---|
[1dc616] | 16 | #endif |
---|
[175e355] | 17 | #endif /* NOSTREAMIO */ |
---|
[684544] | 18 | |
---|
| 19 | |
---|
| 20 | template <class T> |
---|
| 21 | class Factor { |
---|
| 22 | private: |
---|
| 23 | T _factor; |
---|
| 24 | int _exp; |
---|
| 25 | public: |
---|
| 26 | Factor() : _factor(1), _exp(0) {} |
---|
| 27 | Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {} |
---|
| 28 | Factor( const T & f, int e ) : _factor(f), _exp(e) {} |
---|
| 29 | Factor( const T & f ) : _factor(f), _exp(1) {} |
---|
| 30 | ~Factor() {} |
---|
| 31 | Factor<T>& operator= ( const Factor<T>& ); |
---|
| 32 | Factor<T>& operator= ( const T& ); |
---|
| 33 | T factor() const { return _factor; } |
---|
| 34 | int exp() const { return _exp; } |
---|
| 35 | T value() const { return power( _factor, _exp ); } |
---|
| 36 | Factor<T>& operator+= ( int i ) { _exp += i; return *this; } |
---|
| 37 | Factor<T>& operator*= ( int i ) { _exp *= i; return *this; } |
---|
| 38 | Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; } |
---|
[175e355] | 39 | #ifndef NOSTREAMIO |
---|
[181148] | 40 | void print ( OSTREAM& ) const; |
---|
[175e355] | 41 | #endif /* NOSTREAMIO */ |
---|
[684544] | 42 | }; |
---|
| 43 | |
---|
[d2b5a7] | 44 | template <class T> int |
---|
| 45 | operator== ( const Factor<T>&, const Factor<T>& ); |
---|
| 46 | |
---|
[175e355] | 47 | #ifndef NOSTREAMIO |
---|
[684544] | 48 | template <class T> |
---|
[181148] | 49 | OSTREAM& operator<< ( OSTREAM & os, const Factor<T> & f ); |
---|
[175e355] | 50 | #endif /* NOSTREAMIO */ |
---|
[684544] | 51 | |
---|
[6ab5981] | 52 | #endif /* ! INCL_FACTOR_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.