00001 #ifndef included_CTBmatrix
00002 #define included_CTBmatrix 1
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "CTBgrab.hxx"
00017 #include "CTBrawBuffer.hxx"
00018 #include "CTBrange.hxx"
00019 #include "CTBvectorDsc.hxx"
00020 #include "CTBmatrixDsc.hxx"
00021
00022 template <class T>
00023 class CTBmatrix {
00024
00025 public:
00026
00027 typedef T Elem_t;
00028
00029 CTBmatrix();
00030
00031 CTBmatrix(CTBint i_nrow, CTBint i_ncol);
00032 CTBmatrix(CTBint i_nrow, CTBint i_ncol, const T& def);
00033 CTBmatrix(CTBint i_nrow, CTBint i_ncol,
00034 const T& def, const T& defdiag);
00035 CTBmatrix(const CTBmatrix<T>& rhs);
00036 CTBmatrix(CTBmatrix<T>& rhs, bool b_grab);
00037
00038 virtual ~CTBmatrix();
00039
00040 CTBint NRow() const;
00041 CTBint NColumn() const;
00042 CTBint Size() const;
00043 CTBint Capacity() const;
00044
00045 CTBvectorDsc<T> Row(CTBint i_row);
00046 CTBvectorCDsc<T> Row(CTBint i_row) const;
00047
00048 CTBvectorDsc<T> Column(CTBint i_col);
00049 CTBvectorCDsc<T> Column(CTBint i_col) const;
00050
00051 CTBvectorDsc<T> Diagonal();
00052 CTBvectorCDsc<T> Diagonal() const;
00053 CTBvectorDsc<T> Diagonal(CTBint i_dia);
00054 CTBvectorCDsc<T> Diagonal(CTBint i_dia) const;
00055
00056 CTBmatrixDsc<T> Transpose();
00057 CTBmatrixCDsc<T> Transpose() const;
00058
00059 void SwapRow(CTBint i_r1, CTBint i_r2);
00060 void SwapColumn(CTBint i_c1, CTBint i_c2);
00061
00062 T& At (CTBint i_row, CTBint i_col);
00063 const T& At (CTBint i_row, CTBint i_col) const;
00064
00065 void Resize(CTBint i_nrow, CTBint i_ncol);
00066 void Resize(CTBint i_nrow, CTBint i_ncol, const T& def);
00067
00068 void EnsureCapacity(CTBint i_cap);
00069 void IncreaseCapacity(CTBint i_cap);
00070 void TrimCapacity();
00071
00072 void Grab(CTBmatrix<T>& rhs);
00073
00074 const T* Data() const;
00075 CTBint StrideRow() const;
00076 CTBint StrideColumn() const;
00077
00078 void Dump(int i_indent=0, ostream& os=cout,
00079 const char* p_text=0) const;
00080
00081 CTBvectorDsc<T> operator[](CTBint i_row);
00082 CTBvectorCDsc<T> operator[](CTBint i_row) const;
00083
00084 T& operator()(CTBint i_row, CTBint i_col);
00085 const T& operator()(CTBint i_row, CTBint i_col) const;
00086
00087 CTBvectorDsc<T> operator()(CTBint i_row, const CTBrange& rcol);
00088 CTBvectorCDsc<T> operator()(CTBint i_row, const CTBrange& rcol) const;
00089 CTBvectorDsc<T> operator()(const CTBrange& rrow, CTBint i_col);
00090 CTBvectorCDsc<T> operator()(const CTBrange& rrow, CTBint i_col) const;
00091
00092 CTBmatrixDsc<T> operator()(const CTBrange& rrow, const CTBrange& rcol);
00093 CTBmatrixCDsc<T> operator()(const CTBrange& rrow,
00094 const CTBrange& rcol) const;
00095
00096 bool operator!() const;
00097
00098 operator T*();
00099 operator const T*() const;
00100
00101 operator CTBmatrixDsc<T>();
00102 operator CTBmatrixCDsc<T>() const;
00103
00104 CTBmatrix<T>& operator=(const T& rhs);
00105 CTBmatrix<T>& operator=(const CTBmatrix<T>& rhs);
00106 CTBmatrix<T>& operator=(const CTBmatrixCDsc<T>& rhs);
00107
00108 private:
00109
00110 void ChangeCapacity(CTBint i_cap);
00111
00112 private:
00113
00114 CTBrawBuffer<T> m_rbuf;
00115 CTBint mi_nrow;
00116 CTBint mi_ncol;
00117 };
00118
00119 template <class T>
00120 ostream& operator<<(ostream& os, const CTBmatrix<T>& obj);
00121
00122 template <class T>
00123 class CTBgrab<CTBmatrix<T> > : public CTBgrabable<CTBmatrix<T> > {};
00124
00125
00126
00127
00128 #if !(defined(CTB__NoInline) || defined(CTBmatrix__NoInline))
00129 #include "CTBmatrix.icc"
00130 #endif
00131
00132 #endif