#include <iostream>
#include <TNL/Matrices/SparseMatrix.h>
#include <TNL/Matrices/DenseMatrix.h>
#include <TNL/Matrices/MatrixReader.h>
#include <TNL/Matrices/MatrixWriter.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
template< typename Device >
void
matrixWriterExample()
{
Matrix matrix( 5,
5,
{
{ 0, 0, 2.0 },
{ 1, 0, -1.0 }, { 1, 1, 2.0 }, { 1, 2, -1.0 },
{ 2, 1, -1.0 }, { 2, 2, 2.0 }, { 2, 3, -1.0 },
{ 3, 2, -1.0 }, { 3, 3, 2.0 }, { 3, 4, -1.0 },
{ 4, 4, 2.0 }
} );
std::cout <<
"Writing matrix in Gnuplot format into the file matrix-writer-example.gplt ...";
std::cout <<
"Writing matrix pattern in EPS format into the file matrix-writer-example.eps ...";
std::cout <<
"Writing matrix in MTX format into the file matrix-writer-example.mtx ...";
}
template< typename Device >
void
matrixReaderExample()
{
SparseMatrix sparseMatrix;
std::cout <<
"Reading sparse matrix from MTX file matrix-writer-example.mtx ... ";
DenseMatrix denseMatrix;
std::cout <<
"Reading dense matrix from MTX file matrix-writer-example.mtx ... ";
}
int
main( int argc, char* argv[] )
{
matrixWriterExample< TNL::Devices::Host >();
matrixReaderExample< TNL::Devices::Host >();
#ifdef __CUDACC__
matrixWriterExample< TNL::Devices::Cuda >();
matrixReaderExample< TNL::Devices::Cuda >();
#endif
}
Implementation of dense matrix, i.e. matrix storing explicitly all of its elements including zeros.
Definition DenseMatrix.h:31
static void readMtx(const std::string &fileName, Matrix &matrix, bool verbose=false)
Method for importing matrix from file with given filename.
Definition MatrixReader.hpp:19
static void writeEps(const std::string &fileName, const Matrix &matrix, bool verbose=false)
Method for exporting matrix to file with given filename using EPS format.
Definition MatrixWriter.hpp:51
static void writeGnuplot(const std::string &fileName, const Matrix &matrix, bool verbose=false)
Method for exporting matrix to file with given filename using Gnuplot format.
Definition MatrixWriter.hpp:15
static void writeMtx(const std::string &fileName, const Matrix &matrix, bool verbose=false)
Method for exporting matrix to file with given filename using MTX format.
Definition MatrixWriter.hpp:33
Implementation of sparse matrix, i.e. matrix storing only non-zero elements.
Definition SparseMatrix.h:57