#include "densematrix.h" #include "sparsematrix.h" int main(int argc, char *argv[]) { const int nrows = 4; const int ncols = 5; int i, j; DenseMatrix densemat(nrows, ncols); for (i = 0; i < nrows; i++) for(j = 0; j < ncols; j++) densemat(i, j) = 1 + j + i * ncols; cout << "dense matrix\n" << densemat; SparseMatrix sparsemat(nrows, ncols); for (i = 0; i < nrows; i++) for(j = 0; j < ncols; j++) if (i % 2 - j % 2) sparsemat(i, j) = 1 + j + i * ncols; cout << "sparse matrix\n" << sparsemat; return 0; }