My Project  UNKNOWN_GIT_VERSION
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 #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 template <class T>
17 class SubMatrix;
18 
19 template <class T>
20 class Matrix;
21 
22 #ifndef NOSTREAMIO
23 template <class T>
25 #endif
26 
27 template <class T>
28 class Matrix
29 {
30 private:
31  int NR, NC;
32  T ** elems;
33 #ifndef NOSTREAMIO
34  void printrow ( OSTREAM & s, int i ) const;
35 #endif /* NOSTREAMIO */
36  typedef T* T_ptr;
37 public:
38  Matrix() : NR(0), NC(0), elems(0) {}
39  Matrix( int nr, int nc );
40  Matrix( const Matrix<T>& M );
41  ~Matrix();
42  Matrix<T>& operator= ( const Matrix<T>& M );
43  int rows() const { return NR; }
44  int columns() const { return NC; }
45  SubMatrix<T> operator[] ( int i );
46  const SubMatrix<T> operator[] ( int i ) const;
47  T& operator() ( int row, int col );
48  T operator() ( int row, int col ) const;
49  SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax );
50  const SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ) const;
51  void swapRow( int i, int j );
52  void swapColumn( int i, int j );
53 #ifndef NOSTREAMIO
54  void print( OSTREAM& s ) const;
55  friend OSTREAM & operator<< <T>( OSTREAM & s, const Matrix<T>& M );
56 #endif /* NOSTREAMIO */
57  friend class SubMatrix<T>;
58 };
59  /*template <class T>
60  Matrix<T> operator+ ( const Matrix<T>& lhs, const Matrix<T>& rhs );
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 T& rhs );
67  template <class T>
68  Matrix<T> operator* ( const T& lhs, const Matrix<T>& rhs );*/
69 
70 template <class T>
71 class SubMatrix
72 {
73 private:
76  // we do not provide a default ctor, so nobody can declare an empty SubMatrix
77  SubMatrix( int rmin, int rmax, int cmin, int cmax, const Matrix<T> & m );
78 public:
79  SubMatrix( const SubMatrix<T> & S );
81  SubMatrix<T>& operator= ( const Matrix<T>& S );
82  operator Matrix<T>() const;
83  T operator[] ( int i ) const;
84  T& operator[] ( int i );
85  friend class Matrix<T>;
86 };
87 
88 #ifndef NOSTREAMIO
89 template <class T>
90 OSTREAM & operator<< ( OSTREAM & s, const Matrix<T>& M );
91 #endif /* NOSTREAMIO */
92 
93 #endif /* ! INCL_MATRIX_H */
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
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:75
T ** elems
Definition: ftmpl_matrix.h:32
SubMatrix< T > operator[](int i)
Definition: ftmpl_matrix.cc:68
T operator[](int i) const
#define M
Definition: sirandom.c:24
void swapColumn(int i, int j)
int rows() const
Definition: ftmpl_matrix.h:43
int columns() const
Definition: ftmpl_matrix.h:44
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
void swapRow(int i, int j)
T * T_ptr
Definition: ftmpl_matrix.h:36
OSTREAM & operator<<(OSTREAM &, const Matrix< T > &)
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:31
friend class Matrix< T >
Definition: ftmpl_matrix.h:85
SubMatrix< T > & operator=(const SubMatrix< T > &S)
int NR
Definition: ftmpl_matrix.h:31
static jList * T
Definition: janet.cc:31
#define OSTREAM
Definition: ftmpl_matrix.h:9