1#ifndef UTIL_D_SYMM_MATRIX_PARAM_H
2#define UTIL_D_SYMM_MATRIX_PARAM_H
11#include <util/param/MatrixParam.h>
12#include <util/containers/DMatrix.h>
13#include <util/format/Int.h>
14#include <util/format/Dbl.h>
16#include <util/mpi/MpiSendRecv.h>
98 virtual void bcastValue();
127 template <
class Type>
142 template <
class Type>
146 if (!(matrixPtr_->isAllocated())) {
147 UTIL_THROW(
"Cannot read unallocated DMatrix");
149 if (
n() != matrixPtr_->capacity1()) {
150 UTIL_THROW(
"Error: Logical size n() != DMatrix<Type>::capacity1()");
152 if (
n() != matrixPtr_->capacity2()) {
153 UTIL_THROW(
"Error: Logical size n() != DMatrix<Type>::capacity2()");
161 for (i = 0; i <
n(); ++i) {
162 for (j = 0; j <
n(); ++j) {
164 (*matrixPtr_)(i, j) = 0.0;
174 std::stringstream stream;
185 (*matrixPtr_)(i, j) = value;
189 (*matrixPtr_)(j, i) = value;
193 if (k == (
n()+1)*
n()/2) {
205 template <
class Type>
208 if (!(matrixPtr_->isAllocated())) {
209 matrixPtr_->allocate(
n(),
n());
211 if (
n() != matrixPtr_->capacity1()) {
212 UTIL_THROW(
"Error: Logical size n() != DMatrix<Type>::capacity1()");
214 if (
n() != matrixPtr_->capacity2()) {
215 UTIL_THROW(
"Error: Logical size n() != DMatrix<Type>::capacity2()");
224 template <
class Type>
227 if (
n() != matrixPtr_->capacity1()) {
228 UTIL_THROW(
"Error: Logical size n() != DMatrix<Type>::capacity1()");
230 if (
n() != matrixPtr_->capacity2()) {
231 UTIL_THROW(
"Error: Logical size n() != DMatrix<Type>::capacity2()");
240 template <
class Type>
243 if (!(matrixPtr_->isAllocated())) {
244 matrixPtr_->allocate(n(), n());
246 if (n() != matrixPtr_->capacity1()) {
247 UTIL_THROW(
"Error: Logical size n() > DMatrix<Type>::capacity1()");
249 if (n() != matrixPtr_->capacity2()) {
250 UTIL_THROW(
"Error: Logical size n() > DMatrix<Type>::capacity2()");
253 bcast<Type>(ioCommunicator(), *matrixPtr_, n(), n(), 0);
260 template <
class Type>
265 if (!(matrixPtr_->isAllocated())) {
266 UTIL_THROW(
"Cannot read unallocated DMatrix");
268 if (
n() > matrixPtr_->capacity1()) {
269 UTIL_THROW(
"Error: Logical size n() > DMatrix<Type>::capacity1()");
271 if (
n() > matrixPtr_->capacity2()) {
272 UTIL_THROW(
"Error: Logical size n() > DMatrix<Type>::capacity2()");
280 for (i = 0; i <
n(); ++i) {
281 for (j = 0; j <= i; ++j) {
287 out <<
Int(i, 4) <<
" " <<
Int(j, 4) <<
" "
288 << std::right << std::scientific
291 << (*matrixPtr_)(i, j)
Dynamically allocated Matrix.
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
A Parameter associated with a square symmetric DMatrix.
virtual void readValue(std::istream &in)
Read parameter value from an input stream.
void writeParam(std::ostream &out) const
Write symmetric DMatrix to file.
std::string indent() const
Return indent string for this object (string of spaces).
virtual void loadValue(Serializable::IArchive &ar)
Load bare parameter value from an archive.
DSymmMatrixParam(const char *label, DMatrix< Type > &matrix, int n, bool isRequired=true)
Constructor.
virtual void saveValue(Serializable::OArchive &ar)
Save parameter value to an archive.
Label label_
Label object that contains parameter label string.
bool isActive() const
Is this parameter active?
Wrapper for an int, for formatted ostream output.
A label string in a file format.
int m() const
Get the logical array dimension.
std::string label() const
Return label string.
void setBrackets(std::string lBracket, std::string rBracket)
Set left and right bracket / delimiter strings.
void readEndBracket(std::istream &in)
Read the closing delimiter, if any.
void writeEndBracket(std::ostream &out) const
Write the end bracket delimiter, if any.
bool hasBrackets() const
Are brackets being used as delimiters?
bool isRequired() const
Is this an optional parameter?
MatrixParam(const char *label, int m, int n, bool isRequired=true)
Constructor.
int n() const
Get the logical array dimension.
std::string indent() const
Return indent string for this object (string of spaces).
static const int Precision
Precision for io of floating point data field.
Label label_
Label object that contains parameter label string.
bool isActive() const
Is this parameter active?
static const int Width
Width of output field for a scalar variable.
BinaryFileIArchive IArchive
Type of input archive used by load method.
BinaryFileOArchive OArchive
Type of output archive used by save method.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
BracketPolicy::Type get()
Get value of bracket policy.
Utility classes for scientific computation.