#ifndef HPC_GEMATRIX_H #define HPC_GEMATRIX_H 1 #include #include #include "bench.h" namespace matvec { enum class StorageOrder { ColMajor, RowMajor }; template struct GeMatrixView; template struct GeMatrix { typedef T ElementType; typedef I Index; typedef GeMatrix NoView; typedef GeMatrixView View; GeMatrix(Index m, Index n, StorageOrder order=StorageOrder::ColMajor) : m(m), n(n), incRow(order==StorageOrder::ColMajor ? 1: n), incCol(order==StorageOrder::RowMajor ? 1: m), data(new T[m*n]) { } ~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 GeMatrixView View; GeMatrixView(Index m, Index n, T *data, Index incRow, Index incCol) : m(m), n(n), incRow(incRow), incCol(incCol), data(data) { } GeMatrixView(const GeMatrixView &rhs) : m(rhs.m), n(rhs.n), incRow(rhs.incRow), incCol(rhs.incCol), data(rhs.data) { } const ElementType & operator()(Index i, Index j) const { assert(i void initGeMatrix(GeMatrix &A, InitValue initValue) { bench::initGeMatrix(A.m, A.n, A.data, A.incRow, A.incCol, initValue); } template typename GeMatrix::ElementType asumDiffGeMatrix(const GeMatrix &A, const GeMatrix &B) { return bench::asumDiffGeMatrix(A.m, A.n, A.data, A.incRow, A.incCol, B.data, B.incRow, B.incCol); } } // namespace matvec #endif // HPC_GEMATRIX_H