1 #ifndef UTIL_DMATRIX_PARAM_H 2 #define UTIL_DMATRIX_PARAM_H 11 #include <util/param/Parameter.h> 12 #include <util/containers/DMatrix.h> 107 template <
class Type>
112 UTIL_THROW(
"Cannot read unallocated DMatrix");
115 UTIL_THROW(
"Error: Logical size m_ != DMatrix<Type>::capacity1()");
118 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity2()");
122 for (i = 0; i < m_; ++i) {
123 for (j = 0; j < n_; ++j) {
124 in >> (*matrixPtr_)(i, j);
132 template <
class Type>
139 UTIL_THROW(
"Error: Logical size m_ != DMatrix<Type>::capacity1()");
142 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity2()");
151 template <
class Type>
155 UTIL_THROW(
"Error: Logical size m_ != DMatrix<Type>::capacity1()");
158 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity2()");
167 template <
class Type>
174 UTIL_THROW(
"Error: Logical size m_ > DMatrix<Type>::capacity1()");
177 UTIL_THROW(
"Error: Logical size n_ > DMatrix<Type>::capacity2()");
187 template <
class Type>
193 UTIL_THROW(
"Cannot read unallocated DMatrix");
196 UTIL_THROW(
"Error: Logical size m_ > DMatrix<Type>::capacity1()");
199 UTIL_THROW(
"Error: Logical size n_ > DMatrix<Type>::capacity2()");
204 for (i = 0; i < m_; ++i) {
210 for (j = 0; j < n_; ++j) {
211 out << std::right << std::scientific
214 << (*matrixPtr_)(i, j);
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
std::string label() const
Return label string.
virtual void loadValue(Serializable::IArchive &ar)
Load bare parameter value from an archive.
Label label_
Label object that contains parameter label string.
A single variable in a parameter file.
File containing preprocessor macros for error handling.
void writeParam(std::ostream &out)
Write DMatrix to file.
Saving / output archive for binary ostream.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
int capacity2() const
Get number of columns (range of the second array index).
A Parameter associated with a 2D built-in C array.
MPI::Intracomm & ioCommunicator() const
Get the MPI communicator by reference.
Utility classes for scientific computation.
static const int Precision
Precision for io of floating point data field.
bool isActive() const
Is this parameter active?
int capacity1() const
Get number of rows (range of the first array index).
virtual void saveValue(Serializable::OArchive &ar)
Save parameter value to an archive.
A label string in a file format.
Saving archive for binary istream.
static const int Width
Width of output field for a scalar variable.
This file contains templates for global functions send<T>, recv<T> and bcast<T>.
bool isRequired() const
Is this an optional parameter?
virtual void bcastValue()
Broadcast parameter value within the ioCommunicator.
std::string indent() const
Return indent string for this object (string of spaces).
bool isAllocated() const
Return true if the DMatrix has been allocated, false otherwise.
virtual void readValue(std::istream &in)
Read parameter value from an input stream.
DMatrixParam(const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired=true)
Constructor.