61 std::string out = trim_and_lowercase (
objectType);
71 throw std::invalid_argument(
"Object type \"" + out +
"\" is "
72 "not one of the valid values");
81 std::string out = trim_and_lowercase (
matrixType);
83 const char*
const validValues[] = {
"coordinate",
"array"};
86 throw std::invalid_argument(
"Matrix type \"" + out +
"\" is not one of the valid values");
95 std::string out = trim_and_lowercase (
dataType);
97 const char*
const validValues[] = {
"real",
"complex",
"integer",
"pattern"};
100 throw std::invalid_argument(
"Data type \"" + out +
"\" is not one of the valid values");
109 std::string out = trim_and_lowercase (
symmType);
114 {
"general",
"nonsymmetric",
"unsymmetric",
"symmetric",
115 "skew-symmetric",
"skew",
"hermitian"};
118 throw std::invalid_argument(
"Symmetry type \"" + out +
"\" is not one of the valid values");
121 if (out ==
"nonsymmetric" || out ==
"unsymmetric")
122 return std::string(
"general");
123 else if (out ==
"skew")
124 return std::string(
"skew-symmetric");
131 const char*
const validValues[] = {
"general",
"symmetric",
"skew-symmetric",
"hermitian"};
134 throw std::invalid_argument(
"Symmetry type \"" + out +
"\" is not one of the valid values");
164 throw std::invalid_argument (
"The banner line is empty");
167 start =
line.find_first_not_of (
" \t");
168 if (start == std::string::npos) {
174 throw std::invalid_argument (
"The banner line contains only "
175 "whitespace characters");
178 else if (start != 0 && !
tolerant) {
181 throw std::invalid_argument (
"The banner line is not allowed to start "
182 "with whitespace characters");
191 if (
ppStart == std::string::npos) {
197 "Market file's banner line should always start with \"%%\". Here "
198 "is the offending line: " << std::endl <<
line);
211 "Market file's banner line needs to contain information after the "
212 "\"%%\" marker. Here is the offending line: " << std::endl <<
line);
221 std::vector<std::string>
tokens = split (
line,
" \t", 2);
230 "Market file's banner line must always begin with the \"Matrix"
231 "Market\" keyword. Here is the offending line: " << std::endl
238 "Market file's banner line must always begin with the \"Matrix"
239 "Market\" keyword. Here is the offending line: " << std::endl
248 "Market file's banner line must always have 5 tokens, but yours "
250 <<
". Here is the offending line: " << std::endl <<
line);
270 out <<
"%%MatrixMarket"
271 <<
" " <<
banner.objectType()
272 <<
" " <<
banner.matrixType()
273 <<
" " <<
banner.dataType()
274 <<
" " <<
banner.symmType();
Standard test and throw macros.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Parse a Matrix Market banner line.
static std::string validateDataType(const std::string &dataType, const bool tolerant=false)
static std::string validateObjectType(const std::string &objectType, const bool tolerant=false)
Banner(const std::string &line, const bool tolerant=false)
const std::string & symmType() const
Symmetric storage type.
const std::string & objectType() const
The object type.
static std::string validateSymmType(const std::string &symmType, const bool tolerant=false)
static std::string validateMatrixType(const std::string &matrixType, const bool tolerant=false)
const std::string & dataType() const
Data type of matrix entries.
const std::string & matrixType() const
Storage type of the matrix.
void setDefaults(const int howMany)
Set the last howMany member data to default values.
Concrete serial communicator subclass.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Matrix Market file utilities.
std::vector< std::string > split(const std::string &str, const std::string &delimiters, const size_t start)
Split the given string using the given set of delimiters.
std::string trim_and_lowercase(const std::string &in)
Trim whitespace from both sides, and make lowercase.
std::ostream & operator<<(std::ostream &out, const Banner &banner)