34 template<
class Form,
class Type>
45 template<
class Form,
class Type>
51 is.
fatalCheck(
"operator>>(Istream&, Matrix<Form, Type>&)");
57 "operator>>(Istream&, Matrix<Form, Type>&) : reading first token" 65 label mn = M.mRows_*M.nCols_;
68 if (is.
format() == IOstream::ASCII || !contiguous<Type>())
78 if (listDelimiter == token::BEGIN_LIST)
83 for (
label i=0; i<M.
m(); i++)
87 for (
label j=0; j<M.
n(); j++)
93 "operator>>(Istream&, Matrix<Form, Type>&) : " 108 "operator>>(Istream&, Matrix<Form, Type>&) : " 109 "reading the single entry" 112 for (
label i=0; i<mn; i++)
129 is.
read(reinterpret_cast<char*>(v), mn*
sizeof(Type));
133 "operator>>(Istream&, Matrix<Form, Type>&) : " 134 "reading the binary block" 142 <<
"incorrect first token, expected <int>, found " 151 template<
class Form,
class Type>
152 Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>&
M)
154 label mn = M.mRows_*M.nCols_;
156 os << M.
m() << token::SPACE << M.
n();
159 if (os.format() == IOstream::ASCII || !contiguous<Type>())
165 const Type* v = M.v_;
167 if (mn > 1 && contiguous<Type>())
171 for (
label i=0; i<mn; i++)
184 os << token::BEGIN_BLOCK;
190 os << token::END_BLOCK;
192 else if (mn < 10 && contiguous<Type>())
195 os << token::BEGIN_LIST;
200 for (
label i=0; i<M.
m(); i++)
202 os << token::BEGIN_LIST;
205 for (
label j=0; j< M.
n(); j++)
207 if (j > 0) os << token::SPACE;
211 os << token::END_LIST;
215 os << token::END_LIST;
220 os <<
nl << token::BEGIN_LIST;
225 for (
label i=0; i<M.
m(); i++)
227 os <<
nl << token::BEGIN_LIST;
230 for (
label j=0; j< M.
n(); j++)
235 os <<
nl << token::END_LIST;
239 os <<
nl << token::END_LIST <<
nl;
244 os << token::BEGIN_LIST << token::END_LIST <<
nl;
251 os.write(reinterpret_cast<const char*>(M.v_), mn*
sizeof(Type));
256 os.check(
"Ostream& operator<<(Ostream&, const Matrix&)");
label n() const
Return the number of columns.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
char readEndList(const char *funcName)
InfoProxy< token > info() const
Return info proxy.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A token holds items read from Istream.
Template function to specify if the data of a type are contiguous.
label k
Boltzmann constant.
Matrix()
Null constructor.
virtual Istream & read(token &)=0
Return next token from stream.
Istream & operator>>(Istream &, directionInfo &)
streamFormat format() const
Return current stream format.
char readBeginList(const char *funcName)
void clear()
Clear the Matrix, i.e. set sizes to zero.
label readLabel(Istream &is)
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
A templated (m x n) matrix of objects of <T>.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
label m() const
Return the number of rows.