================ Lösungsvorschlag ================ ==== CODE (type=cc) ============================================================ #ifndef HPC_MATVEC_GEMATRIX_H #define HPC_MATVEC_GEMATRIX_H 1 #include #include #include namespace hpc { namespace matvec { enum class StorageOrder { ColMajor, RowMajor }; template struct GeMatrixView; template struct GeMatrixConstView; template struct GeMatrix { typedef T ElementType; typedef I Index; typedef GeMatrix NoView; typedef GeMatrixConstView ConstView; typedef GeMatrixView View; typedef DenseVectorConstView ConstVectorView; typedef DenseVectorView VectorView; GeMatrix(Index numRows, Index numCols, StorageOrder order=StorageOrder::ColMajor) : numRows(numRows), numCols(numCols), incRow(order==StorageOrder::ColMajor ? 1: numCols), incCol(order==StorageOrder::RowMajor ? 1: numRows), data(new T[numRows*numCols]) { } ~GeMatrix() { delete[] data; } const ElementType & operator()(Index i, Index j) const { assert(i struct GeMatrixView { typedef T ElementType; typedef I Index; typedef GeMatrix NoView; typedef GeMatrixConstView ConstView; typedef GeMatrixView View; typedef DenseVectorConstView ConstVectorView; typedef DenseVectorView VectorView; GeMatrixView(Index numRows, Index numCols, T *data, Index incRow, Index incCol) : numRows(numRows), numCols(numCols), incRow(incRow), incCol(incCol), data(data) { } GeMatrixView(const GeMatrixView &rhs) : numRows(rhs.numRows), numCols(rhs.numCols), incRow(rhs.incRow), incCol(rhs.incCol), data(rhs.data) { } const ElementType & operator()(Index i, Index j) const { assert(i struct GeMatrixConstView { typedef T ElementType; typedef I Index; typedef GeMatrix NoView; typedef GeMatrixConstView ConstView; typedef GeMatrixView View; typedef DenseVectorConstView ConstVectorView; typedef DenseVectorView VectorView; GeMatrixConstView(Index numRows, Index numCols, const T *data, Index incRow, Index incCol) : numRows(numRows), numCols(numCols), incRow(incRow), incCol(incCol), data(data) { } GeMatrixConstView(const GeMatrixConstView &rhs) : numRows(rhs.numRows), numCols(rhs.numCols), incRow(rhs.incRow), incCol(rhs.incCol), data(rhs.data) { } const ElementType & operator()(Index i, Index j) const { assert(i doc:index next -> doc:session19/page05 back -> doc:session19/page03