source: git/factory/templates/ftmpl_afactor.h @ 102a88e

jengelh-datetimespielwiese
Last change on this file since 102a88e was 102a88e, checked in by Martin Lee <martinlee84@…>, 10 years ago
chg: added more functions to templates
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifndef INCL_AFACTOR_H
4#define INCL_AFACTOR_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
18template <class T>
19class AFactor {
20private:
21    T _factor;
22    T _minpoly;
23    int _exp;
24public:
25    AFactor() : _factor(1), _minpoly (1), _exp(0) {}
26    AFactor( const AFactor<T> & f ) : _factor(f._factor), _minpoly (f._minpoly), _exp(f._exp) {}
27    AFactor( const T & f, const T & m, int e ) : _factor(f), _minpoly (m), _exp(e) {}
28    AFactor( const T & f, const T & m ) : _factor(f), _minpoly (m), _exp(1) {}
29    ~AFactor() {}
30    AFactor<T>& operator= ( const AFactor<T>& );
31    T factor() const { return _factor; }
32    T minpoly() const { return _minpoly; }
33    int exp() const { return _exp; }
34    T value() const { return power( _factor, _exp ); }
35#ifndef NOSTREAMIO
36    void print ( OSTREAM& ) const;
37#endif /* NOSTREAMIO */
38};
39
40template <class T> int
41operator== ( const AFactor<T>&, const AFactor<T>& );
42
43#ifndef NOSTREAMIO
44template <class T>
45OSTREAM& operator<< ( OSTREAM & os, const AFactor<T> & f );
46#endif /* NOSTREAMIO */
47
48#endif /* ! INCL_AFACTOR_H */
Note: See TracBrowser for help on using the repository browser.