Changeset 19fc57b in git
- Timestamp:
- Jun 13, 2005, 11:46:35 AM (18 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 9b2e40337f961f59313156623380c600a101bb81
- Parents:
- f6202187ee8c7e5f4a1be04fd61af7b6987429bc
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/ftmpl_matrix.h
rf620218 r19fc57b 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: ftmpl_matrix.h,v 1. 1 1998-03-10 14:43:26 schmidtExp $ */2 /* $Id: ftmpl_matrix.h,v 1.2 2005-06-13 09:46:35 Singular Exp $ */ 3 3 4 4 #ifndef INCL_MATRIX_H 5 #define INCL_MATRIX_H 5 6 6 //{{{ docu 7 // 8 // ftmpl_matrix.h - wrapper for `templates/ftmpl_matrix.h'. 9 // 10 // This file exists for convenience only. 11 // 12 // `INCL_MATRIX_H' is defined in `templates/ftmpl_matrix.h'. 13 // 14 //}}} 7 #include <factoryconf.h> 15 8 16 #ifdef macintosh 17 #include <:templates:ftmpl_matrix.h> 18 #else 19 #include "templates/ftmpl_matrix.h" 9 #ifndef NOSTREAMIO 10 #include <iostream.h> 11 #endif /* NOSTREAMIO */ 12 13 template <class T> 14 class SubMatrix; 15 16 template <class T> 17 class Matrix; 18 19 #ifndef NOSTREAMIO 20 template <class T> 21 ostream& operator<< (ostream &, const Matrix<T> &); 20 22 #endif 21 23 24 template <class T> 25 class Matrix 26 { 27 private: 28 int NR, NC; 29 T ** elems; 30 #ifndef NOSTREAMIO 31 void printrow ( ostream & s, int i ) const; 32 #endif /* NOSTREAMIO */ 33 typedef T* T_ptr; 34 public: 35 Matrix() : NR(0), NC(0), elems(0) {} 36 Matrix( int nr, int nc ); 37 Matrix( const Matrix<T>& M ); 38 ~Matrix(); 39 Matrix<T>& operator= ( const Matrix<T>& M ); 40 int rows() const { return NR; } 41 int columns() const { return NC; } 42 SubMatrix<T> operator[] ( int i ); 43 const SubMatrix<T> operator[] ( int i ) const; 44 T& operator() ( int row, int col ); 45 T operator() ( int row, int col ) const; 46 SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ); 47 const SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ) const; 48 void swapRow( int i, int j ); 49 void swapColumn( int i, int j ); 50 #ifndef NOSTREAMIO 51 void print( ostream& s ) const; 52 friend ostream & operator<< <T>( ostream & s, const Matrix<T>& M ); 53 #endif /* NOSTREAMIO */ 54 friend class SubMatrix<T>; 55 }; 56 template <class T> 57 Matrix<T> operator+ ( const Matrix<T>& lhs, const Matrix<T>& rhs ); 58 template <class T> 59 Matrix<T> operator- ( const Matrix<T>& lhs, const Matrix<T>& rhs ); 60 template <class T> 61 Matrix<T> operator* ( const Matrix<T>& lhs, const Matrix<T>& rhs ); 62 template <class T> 63 Matrix<T> operator* ( const Matrix<T>& lhs, const T& rhs ); 64 template <class T> 65 Matrix<T> operator* ( const T& lhs, const Matrix<T>& rhs ); 66 67 template <class T> 68 class SubMatrix 69 { 70 private: 71 int r_min, r_max, c_min, c_max; 72 Matrix<T>& M; 73 // we do not provide a default ctor, so nobody can declare an empty SubMatrix 74 SubMatrix( int rmin, int rmax, int cmin, int cmax, const Matrix<T> & m ); 75 public: 76 SubMatrix( const SubMatrix<T> & S ); 77 SubMatrix<T>& operator= ( const SubMatrix<T>& S ); 78 SubMatrix<T>& operator= ( const Matrix<T>& S ); 79 operator Matrix<T>() const; 80 T operator[] ( int i ) const; 81 T& operator[] ( int i ); 82 friend class Matrix<T>; 83 }; 84 85 #ifndef NOSTREAMIO 86 template <class T> 87 ostream & operator<< ( ostream & s, const Matrix<T>& M ); 88 #endif /* NOSTREAMIO */ 89 22 90 #endif /* ! INCL_MATRIX_H */ -
factory/templates/ftmpl_matrix.h
rf620218 r19fc57b 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: ftmpl_matrix.h,v 1.1 0 2005-01-13 15:11:36Singular Exp $ */2 /* $Id: ftmpl_matrix.h,v 1.11 2005-06-13 09:46:35 Singular Exp $ */ 3 3 4 4 #ifndef INCL_MATRIX_H … … 19 19 #ifndef NOSTREAMIO 20 20 template <class T> 21 std::ostream& operator<< (std::ostream &, const Matrix<T> &);21 ostream& operator<< (ostream &, const Matrix<T> &); 22 22 #endif 23 23
Note: See TracChangeset
for help on using the changeset viewer.