00001 00027 #ifndef SGDK_ZREF_MATRIX_HPP 00028 #define SGDK_ZREF_MATRIX_HPP 00029 00030 #include <vector> // std::vector 00031 00032 namespace sgdk { 00033 00035 00094 template < 00095 #ifndef SGDK_DOX 00096 typename Value 00097 , typename Size = unsigned int 00098 #endif /* SGDK_DOX */ 00099 > 00100 class DenseMatrix 00101 { 00102 private: 00103 typedef std::vector<Value> Row; 00104 00105 public: 00109 typedef Value value_type; 00110 00115 #ifdef SGDK_DOX 00116 typedef implementation_defined reference; 00117 #else 00118 typedef typename Row::reference reference; 00119 #endif /* SGDK_DOX */ 00120 00125 #ifdef SGDK_DOX 00126 typedef implementation_defined const_reference; 00127 #else 00128 typedef typename Row::const_reference const_reference; 00129 #endif /* SGDK_DOX */ 00130 00131 private: 00132 std::vector<Row> _matrix; 00133 00134 public: 00136 00143 DenseMatrix(const Size row_count = 2, const Size column_count = 2) 00144 : _matrix(row_count, Row(column_count, Value())) 00145 { 00146 } 00147 00149 00155 DenseMatrix(const DenseMatrix& copy) 00156 : _matrix(copy._matrix) 00157 { 00158 } 00159 00161 00168 DenseMatrix& operator=(const DenseMatrix& copy) 00169 { 00170 _matrix = copy._matrix; 00171 return *this; 00172 } 00173 00185 inline reference operator()(const Size row, const Size column) 00186 { 00187 return _matrix[row][column]; 00188 } 00189 00201 inline const_reference operator()(const Size row, const Size column) const 00202 { 00203 return _matrix[row][column]; 00204 } 00205 00213 void resize(const Size row_count, const Size column_count); 00214 }; 00215 00216 #ifndef SGDK_DOX 00217 template <typename Value, typename Size> 00218 #endif /* SGDK_DOX */ 00219 void 00220 DenseMatrix< 00221 #ifndef SGDK_DOX 00222 Value 00223 , Size 00224 #endif /* SGDK_DOX */ 00225 >::resize(const Size row_count, const Size column_count) 00226 { 00227 _matrix.clear(); 00228 _matrix.resize(row_count, Row(column_count, Value())); 00229 } 00230 } // namespace sgdk 00231 00232 #endif /* SGDK_ZREF_MATRIX_HPP */
Swiss GD Knife is hosted by .