34 template<
class Form,
class Type>
45 template<
class Form,
class Type>
48 if (token::compound::isCompound(Form::typeName()))
50 os << Form::typeName() <<
" ";
57 template<
class Form,
class Type>
63 is.
fatalCheck(
"operator>>(Istream&, Matrix<Form, Type>&)");
69 "operator>>(Istream&, Matrix<Form, Type>&) : reading first token" 87 label mn = M.mRows_*M.nCols_;
90 if (is.
format() == IOstream::ASCII || !contiguous<Type>())
100 if (listDelimiter == token::BEGIN_LIST)
105 for (
label i=0; i<M.
m(); i++)
109 for (
label j=0; j<M.
n(); j++)
115 "operator>>(Istream&, Matrix<Form, Type>&) : " 130 "operator>>(Istream&, Matrix<Form, Type>&) : " 131 "reading the single entry" 134 for (
label i=0; i<mn; i++)
151 is.
read(reinterpret_cast<char*>(v), mn*
sizeof(Type));
155 "operator>>(Istream&, Matrix<Form, Type>&) : " 156 "reading the binary block" 164 <<
"incorrect first token, expected <int>, found " 173 template<
class Form,
class Type>
174 Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>&
M)
176 label mn = M.mRows_*M.nCols_;
178 os << M.
m() << token::SPACE << M.
n();
181 if (os.format() == IOstream::ASCII || !contiguous<Type>())
187 const Type* v = M.v_;
189 if (mn > 1 && contiguous<Type>())
193 for (
label i=0; i<mn; i++)
206 os << token::BEGIN_BLOCK;
212 os << token::END_BLOCK;
214 else if (mn < 10 && contiguous<Type>())
217 os << token::BEGIN_LIST;
222 for (
label i=0; i<M.
m(); i++)
224 os << token::BEGIN_LIST;
227 for (
label j=0; j< M.
n(); j++)
229 if (j > 0) os << token::SPACE;
233 os << token::END_LIST;
237 os << token::END_LIST;
242 os <<
nl << token::BEGIN_LIST;
247 for (
label i=0; i<M.
m(); i++)
249 os <<
nl << token::BEGIN_LIST;
252 for (
label j=0; j< M.
n(); j++)
257 os <<
nl << token::END_LIST;
261 os <<
nl << token::END_LIST <<
nl;
266 os << token::BEGIN_LIST << token::END_LIST <<
nl;
273 os.write(reinterpret_cast<const char*>(M.v_), mn*
sizeof(Type));
278 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.
compound & transferCompoundToken(const Istream &is)
To & dynamicCast(From &r)
Reference type cast template function,.
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.
A templated class for holding compound tokens.
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...
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
label m() const
Return the number of rows.
void transfer(mType &)
Transfer the contents of the argument Matrix into this Matrix.