Input/output

Display

If Qt5 was detected during Elemental’s configuration process, the following routines draw data structures on screen; otherwise, they print entries to the standard output stream (i.e., std::cout).

Dense matrices

C++ API

void Display(const Matrix<T> &A, std::string title = "Matrix")
void Display(const AbstractDistMatrix<T> &A, std::string title = "DistMatrix")
void Display(const AbstractBlockDistMatrix<T> &A, std::string title = "BlockDistMatrix")

C API

ElError ElDisplay_i(ElConstMatrix_i A, const char* title)
ElError ElDisplay_s(ElConstMatrix_s A, const char* title)
ElError ElDisplay_d(ElConstMatrix_d A, const char* title)
ElError ElDisplay_c(ElConstMatrix_c A, const char* title)
ElError ElDisplay_z(ElConstMatrix_z A, const char* title)
ElError ElDisplayDist_i(ElConstDistMatrix_i A, const char* title)
ElError ElDisplayDist_s(ElConstDistMatrix_s A, const char* title)
ElError ElDisplayDist_d(ElConstDistMatrix_d A, const char* title)
ElError ElDisplayDist_c(ElConstDistMatrix_c A, const char* title)
ElError ElDisplayDist_z(ElConstDistMatrix_z A, const char* title)

Graphs and sparse matrices

C++ API

void Display(const Graph &graph, std::string title = "Graph")
void Display(const DistGraph &graph, std::string title = "DistGraph")
void Display(const SparseMatrix<T> &A, std::string title = "SparseMatrix")
void Display(const DistSparseMatrix<T> &A, std::string title = "DistSparseMatrix")

C API

TODO

Sparse-direct data structures

C++ API

void DisplayLocal(const DistSymmInfo &info, bool beforeFact, std::string title = "")

C API

TODO

Print

The following routines print a given matrix or graph to a given output stream (which defaults to std::cout).

Dense matrices

C++ API

void Print(const Matrix<T> &A, std::string title = "Matrix", std::ostream &os = std::cout)
void Print(const AbstractDistMatrix<T> &A, std::string title = "DistMatrix", std::ostream &os = std::cout)
void Print(const AbstractBlockDistMatrix<T> &A, std::string title = "BlockDistMatrix", std::ostream &os = std::cout)

C API

ElError ElPrint_i(ElConstMatrix_i A, const char* title)
ElError ElPrint_s(ElConstMatrix_s A, const char* title)
ElError ElPrint_d(ElConstMatrix_d A, const char* title)
ElError ElPrint_c(ElConstMatrix_c A, const char* title)
ElError ElPrint_z(ElConstMatrix_z A, const char* title)
ElError ElPrintDist_i(ElConstDistMatrix_i A, const char* title)
ElError ElPrintDist_s(ElConstDistMatrix_s A, const char* title)
ElError ElPrintDist_d(ElConstDistMatrix_d A, const char* title)
ElError ElPrintDist_c(ElConstDistMatrix_c A, const char* title)
ElError ElPrintDist_z(ElConstDistMatrix_z A, const char* title)

Graphs and sparse matrices

C++ API

void Print(const Graph &graph, std::string title = "Graph", std::ostream &os = std::cout)
void Print(const DistGraph &graph, std::string title = "DistGraph", std::ostream &os = std::cout)
void Print(const SparseMatrix<T> &A, std::string title = "SparseMatrix", std::ostream &os = std::cout)
void Print(const DistSparseMatrix<T> &A, std::string title = "DistSparseMatrix", std::ostream &os = std::cout)

C API

TODO

Sparse-direct data structures

C++ API

void PrintLocal(const DistSymmInfo &info, std::string title = "Local DistSymmInfo", std::ostream &os = std::cout)

C API

TODO

Utilities

C++ API

void Print(const std::vector<T> &x, std::string title = "std::vector", std::ostream &os = std::cout)

Spy

If Qt5 was detected during configuration, then the following routines display a sply plot of the elements of a matrix with absolute values greater than or equal to a given tolerance, tol.

Dense matrices

C++ API

void Spy(const Matrix<T> &A, std::string title = "Matrix", Base<T> tol = 0)
void Spy(const AbstractDistMatrix<T> &A, std::string title = "DistMatrix", Base<T> tol = 0)
void Spy(const AbstractBlockDistMatrix<T> &A, std::string title = "BlockDistMatrix", Base<T> tol = 0)

C API

ElError ElSpy_i(ElConstMatrix_i A, const char* title, ElInt tol)
ElError ElSpy_s(ElConstMatrix_s A, const char* title, float tol)
ElError ElSpy_d(ElConstMatrix_d A, const char* title, double tol)
ElError ElSpy_c(ElConstMatrix_c A, const char* title, float tol)
ElError ElSpy_z(ElConstMatrix_z A, const char* title, double tol)
ElError ElSpyDist_i(ElConstDistMatrix_i A, const char* title, ElInt tol)
ElError ElSpyDist_s(ElConstDistMatrix_s A, const char* title, float tol)
ElError ElSpyDist_d(ElConstDistMatrix_d A, const char* title, double tol)
ElError ElSpyDist_c(ElConstDistMatrix_c A, const char* title, float tol)
ElError ElSpyDist_z(ElConstDistMatrix_z A, const char* title, double tol)

Read

File formats

Note

In the case that a BINARY_FLAT file is read, the formed matrix should have already been of the correct size before reading.

C++ API

type FileFormat

An enum that can take on the following values:

  • AUTO: attempt to detect format from filename extension
  • ASCII: simple ASCII text file
  • ASCII_ASCII: MATLAB-ready ASCII text file
  • BINARY: column-major binary file with integer height and width header
  • BINARY_FLAT: column-major binary file with no header data
  • BMP: bitmap image format (requires Qt5)
  • MATRIX_MARKET: Matrix Market format
  • JPG: JPG image format (requires Qt5)
  • JPEG: JPEG image format (requires Qt5)
  • PNG: PNG image format (requires Qt5)
  • PPM: PPM image format (requires Qt5)
  • XBM: XBM image format (requires Qt5)
  • XPM: XPM image format (requires Qt5)

C API

ElFileFormat

An enum that can take on the following values:

  • EL_AUTO: attempt to detect format from filename extension
  • EL_ASCII: simple ASCII text file
  • EL_ASCII_ASCII: MATLAB-ready ASCII text file
  • EL_BINARY: column-major binary file with integer height and width header
  • EL_BINARY_FLAT: column-major binary file with no header data
  • EL_BMP: bitmap image format (requires Qt5)
  • EL_MATRIX_MARKET: Matrix Market format
  • EL_JPG: JPG image format (requires Qt5)
  • EL_JPEG: JPEG image format (requires Qt5)
  • EL_PNG: PNG image format (requires Qt5)
  • EL_PPM: PPM image format (requires Qt5)
  • EL_XBM: XBM image format (requires Qt5)
  • EL_XPM: XPM image format (requires Qt5)

Dense matrices

Elemental supports reading matrices from several different file formats (at the moment, ASCII, BINARY, BINARY_FLAT and MATRIX_MARKET). In the distributed case, the sequential flag determines whether or not the data should be read from file by a single process and then afterward scattered to the entire set of processes.

C++ API

void Read(Matrix<T> &A, std::string filename, FileFormat format = AUTO)
void Read(AbstractDistMatrix<T> &A, std::string filename, FileFormat format = AUTO, bool sequential = false)
void Read(AbstractBlockDistMatrix<T> &A, std::string filename, FileFormat format = AUTO, bool sequential = false)

C API

ElError ElRead_i(ElMatrix_i A, const char* filename, ElFileFormat format)
ElError ElRead_s(ElMatrix_s A, const char* filename, ElFileFormat format)
ElError ElRead_d(ElMatrix_d A, const char* filename, ElFileFormat format)
ElError ElRead_c(ElMatrix_c A, const char* filename, ElFileFormat format)
ElError ElRead_z(ElMatrix_z A, const char* filename, ElFileFormat format)
ElError ElReadDist_i(ElMatrix_i A, const char* filename, ElFileFormat format)
ElError ElReadDist_s(ElMatrix_s A, const char* filename, ElFileFormat format)
ElError ElReadDist_d(ElMatrix_d A, const char* filename, ElFileFormat format)
ElError ElReadDist_c(ElMatrix_c A, const char* filename, ElFileFormat format)
ElError ElReadDist_z(ElMatrix_z A, const char* filename, ElFileFormat format)

Write

Elemental also supports writing matrices to disk in various file formats. However, please note that Qt5 is currently required for writing to image formats.

Dense matrices

C++ API

void Write(const Matrix<T> &A, std::string basename = "Matrix", FileFormat format = BINARY, std::string title = "")
void Write(const AbstractDistMatrix<T> &A, std::string basename = "DistMatrix", FileFormat format = BINARY, std::string title = "")
void Write(const AbstractBlockDistMatrix<T> &A, std::string basename = "BlockDistMatrix", FileFormat format = BINARY, std::string title = "")

C API

ElError ElWrite_i(ElConstMatrix_i A, const char* basename, ElFileFormat format, const char* title)
ElError ElWrite_s(ElConstMatrix_s A, const char* basename, ElFileFormat format, const char* title)
ElError ElWrite_d(ElConstMatrix_d A, const char* basename, ElFileFormat format, const char* title)
ElError ElWrite_c(ElConstMatrix_c A, const char* basename, ElFileFormat format, const char* title)
ElError ElWrite_z(ElConstMatrix_z A, const char* basename, ElFileFormat format, const char* title)
ElError ElWriteDist_i(ElConstDistMatrix_i A, const char* basename, ElFileFormat format, const char* title)
ElError ElWriteDist_s(ElConstDistMatrix_s A, const char* basename, ElFileFormat format, const char* title)
ElError ElWriteDist_d(ElConstDistMatrix_d A, const char* basename, ElFileFormat format, const char* title)
ElError ElWriteDist_c(ElConstDistMatrix_c A, const char* basename, ElFileFormat format, const char* title)
ElError ElWriteDist_z(ElConstDistMatrix_z A, const char* basename, ElFileFormat format, const char* title)