ftmpl_matrix.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 #ifndef INCL_MATRIX_H
4 #define INCL_MATRIX_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 template <class T>
19 class SubMatrix;
20 
21 template <class T>
22 class Matrix;
23 
24 #ifndef NOSTREAMIO
25 template <class T>
26 OSTREAM& operator<< (OSTREAM &, const Matrix<T> &);
27 #endif
28 
29 template <class T>
30 class Matrix
31 {
32 private:
33  int NR, NC;
34  T ** elems;
35 #ifndef NOSTREAMIO
36  void printrow ( OSTREAM & s, int i ) const;
37 #endif /* NOSTREAMIO */
38  typedef T* T_ptr;
39 public:
40  Matrix() : NR(0), NC(0), elems(0) {}
41  Matrix( int nr, int nc );
42  Matrix( const Matrix<T>& M );
43  ~Matrix();
44  Matrix<T>& operator= ( const Matrix<T>& M );
45  int rows() const { return NR; }
46  int columns() const { return NC; }
47  SubMatrix<T> operator[] ( int i );
48  const SubMatrix<T> operator[] ( int i ) const;
49  T& operator() ( int row, int col );
50  T operator() ( int row, int col ) const;
51  SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax );
52  const SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ) const;
53  void swapRow( int i, int j );
54  void swapColumn( int i, int j );
55 #ifndef NOSTREAMIO
56  void print( OSTREAM& s ) const;
57  friend OSTREAM & operator<< <T>( OSTREAM & s, const Matrix<T>& M );
58 #endif /* NOSTREAMIO */
59  friend class SubMatrix<T>;
60 };
61  /*template <class T>
62  Matrix<T> operator+ ( const Matrix<T>& lhs, const Matrix<T>& rhs );
63  template <class T>
64  Matrix<T> operator- ( const Matrix<T>& lhs, const Matrix<T>& rhs );
65  template <class T>
66  Matrix<T> operator* ( const Matrix<T>& lhs, const Matrix<T>& rhs );
67  template <class T>
68  Matrix<T> operator* ( const Matrix<T>& lhs, const T& rhs );
69  template <class T>
70  Matrix<T> operator* ( const T& lhs, const Matrix<T>& rhs );*/
71 
72 template <class T>
73 class SubMatrix
74 {
75 private:
78  // we do not provide a default ctor, so nobody can declare an empty SubMatrix
79  SubMatrix( int rmin, int rmax, int cmin, int cmax, const Matrix<T> & m );
80 public:
81  SubMatrix( const SubMatrix<T> & S );
83  SubMatrix<T>& operator= ( const Matrix<T>& S );
84  operator Matrix<T>() const;
85  T operator[] ( int i ) const;
86  T& operator[] ( int i );
87  friend class Matrix<T>;
88 };
89 
90 #ifndef NOSTREAMIO
91 template <class T>
92 OSTREAM & operator<< ( OSTREAM & s, const Matrix<T>& M );
93 #endif /* NOSTREAMIO */
94 
95 #endif /* ! INCL_MATRIX_H */
const CanonicalForm int s
Definition: facAbsFact.cc:55
void printrow(OSTREAM &s, int i) const
Matrix< T > & operator=(const Matrix< T > &M)
Definition: ftmpl_matrix.cc:47
Matrix< T > & M
Definition: ftmpl_matrix.h:77
T ** elems
Definition: ftmpl_matrix.h:34
SubMatrix< T > operator[](int i)
Definition: ftmpl_matrix.cc:68
T operator[](int i) const
#define M
Definition: sirandom.c:24
int j
Definition: myNF.cc:70
void swapColumn(int i, int j)
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
void swapRow(int i, int j)
T * T_ptr
Definition: ftmpl_matrix.h:38
T & operator()(int row, int col)
Definition: ftmpl_matrix.cc:82
void print(OSTREAM &s) const
SubMatrix(int rmin, int rmax, int cmin, int cmax, const Matrix< T > &m)
int NC
Definition: ftmpl_matrix.h:33
SubMatrix< T > & operator=(const SubMatrix< T > &S)
int NR
Definition: ftmpl_matrix.h:33
static jList * T
Definition: janet.cc:37
#define OSTREAM
Definition: ftmpl_matrix.h:11