Loading Matrices from the "Matrix Market"
The Matrix Market is a repository with hundreds of sparse matrices. Most of these matrices can be downloaded in a file in Harwell-Boeing format. Seldon provides a function to read a subset of these files.
A file from the Matrix Market is associated with a type encoded in three characters (which is usually its extension). The supported types have:
- 'R' (real), 'C' (complex) or 'P' (pattern) as first character;
- 'U' (unsymmetric), 'S' (symmetric) or 'R' (rectangular) as second character; 'H' (Hermitian) and 'Z' (skew symmetric) are not supported;
- 'A' (assembled) as third character; 'E' (elemental) is not supported.
In short, Seldon can read Harwell-Boeing files from the Matrix Market providing their extensions meet the regular expression [rp][ur]a
. Once read, the matrix is stored in a matrix of type Matrix<double, Prop, ColSparse, Allocator>
or Matrix<float, Prop, ColSparse, Allocator>
. Seldon can also write real and complex matrices in Harwell-Boeing files (.rua, .rsa, .cua or .csa extension). The coordinate format (.mtx extension) is also supported by functions ReadMatrixMarket/WriteMatrixMarket.
See the functions:
- Seldon::ReadHarwellBoeing(string filename, Matrix<double, Prop, ColSparse, Allocator>& A).
- Seldon::WriteHarwellBoeing(const Matrix<T, Prop, Storage, Allocator>& A, const string& file_name).
- Seldon::ReadMatrixMarket(string filename, Matrix<double, Prop, ColSparse, Allocator>& A).
- Seldon::WriteMatrixMarket(const Matrix<T, Prop, Storage, Allocator>& A, const string& file_name).
Note that these functions are only available after the file matrix_sparse/IOMatrixMarket.cxx
has been included:
#define SELDON_DEBUG_LEVEL_2
#include "SeldonLib.hxx"
int main(int argc, char** argv)
{
if (argc != 2)
{
cout << "Enter the file name where the matrix is stored" << endl;
cout << "Usage : ./a.out matrice.rua" << endl;
abort();
}
TRY;
ReadHarwellBoeing(argv[1], A);
A.Print();
WriteHarwellBoeing(A, "result.rua");
END;
return 0;
}