1 #ifndef UTIL_D_SYMM_MATRIX_PARAM_H 2 #define UTIL_D_SYMM_MATRIX_PARAM_H 11 #include <util/param/Parameter.h> 12 #include <util/containers/DMatrix.h> 13 #include <util/format/Int.h> 103 template <
class Type>
108 UTIL_THROW(
"Cannot read unallocated DMatrix");
111 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity1()");
114 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity2()");
121 for (i = 0; i < n_; ++i) {
122 for (j = 0; j < n_; ++j) {
128 for (
int k = 0; k < n_*(n_ + 1)/2; ++k) {
129 in >> i >> j >> value;
131 (*matrixPtr_)(i, j) = value;
135 (*matrixPtr_)(j, i) = value;
145 template <
class Type>
152 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity1()");
155 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity2()");
164 template <
class Type>
168 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity1()");
171 UTIL_THROW(
"Error: Logical size n_ != DMatrix<Type>::capacity2()");
180 template <
class Type>
187 UTIL_THROW(
"Error: Logical size n_ > DMatrix<Type>::capacity1()");
190 UTIL_THROW(
"Error: Logical size n_ > DMatrix<Type>::capacity2()");
200 template <
class Type>
206 UTIL_THROW(
"Cannot read unallocated DMatrix");
209 UTIL_THROW(
"Error: Logical size n_ > DMatrix<Type>::capacity1()");
212 UTIL_THROW(
"Error: Logical size n_ > DMatrix<Type>::capacity2()");
217 for (i = 0; i < n_; ++i) {
218 for (j = 0; j <= i; ++j) {
219 if (i == 0 && j == 0) {
224 out <<
Int(i, 4) <<
" " <<
Int(j, 4) <<
" " 225 << std::right << std::scientific
228 << (*matrixPtr_)(i, j)
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
std::string label() const
Return label string.
Label label_
Label object that contains parameter label string.
A single variable in a parameter file.
File containing preprocessor macros for error handling.
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).
virtual void loadValue(Serializable::IArchive &ar)
Load bare parameter value from an archive.
MPI::Intracomm & ioCommunicator() const
Get the MPI communicator by reference.
Utility classes for scientific computation.
DSymmMatrixParam(const char *label, DMatrix< Type > &matrix, int n, bool isRequired=true)
Constructor.
Wrapper for an int, for formatted ostream output.
static const int Precision
Precision for io of floating point data field.
bool isActive() const
Is this parameter active?
virtual void saveValue(Serializable::OArchive &ar)
Save parameter value to an archive.
int capacity1() const
Get number of rows (range of the first array index).
virtual void readValue(std::istream &in)
Read parameter value from an input stream.
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>.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
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.
void writeParam(std::ostream &out)
Write DMatrix to file.
A Parameter associated with a symmetric DMatrix.