11#include <util/containers/DArray.h>
24 template <
typename T =
double>
79 using Array<T>::operator [];
127 if (
this == &other)
return *
this;
134 if (!isAllocated()) {
136 }
else if (capacity_ != other.
capacity_) {
141 for (
int i = 0; i < capacity_; ++i) {
151 template <
typename T>
154 if (!isAllocated()) {
157 for (
int i = 0; i < capacity_; ++i) {
166 template <
typename T>
172 if (!isAllocated()) {
178 for (
int i = 0; i < capacity_; ++i) {
179 data_[i] += other.
data_[i];
187 template <
typename T>
195 if (!isAllocated()) {
202 for (
int i = 0; i < capacity_; ++i) {
203 data_[i] -= other.
data_[i];
211 template <
typename T>
215 if (!isAllocated()) {
219 for (
int i = 0; i < capacity_; ++i) {
228 template <
typename T>
235 if (!isAllocated()) {
242 for (
int i = 0; i < capacity_; ++i) {
243 data_[i] *= other.
data_[i];
251 template <
typename T>
254 for (
int i = 0; i < capacity_; ++i) {
262 template <
typename T>
266 for (
int i = 0; i < capacity_; ++i) {
269 return value/T(capacity_);
Base class template for a field defined on a spatial grid.
Field< T > & operator-=(Field< T > &other)
Decrement operator - subtract one field from another.
T average() const
Compute and return average of all elements.
Field< T > & operator*=(T scalar)
Multiplication operator - multiply one field by a scalar.
void setToZero()
Set all elements to zero.
Field< T > & operator=(Field< T > const &other)
Assignment operator.
Field(Field< T > const &other)
Copy constructor.
Field< T > & operator+=(Field< T > &other)
Increment operator - add one field by another.
Array container class template.
Data * data_
Pointer to an array of Data elements.
int capacity() const
Return allocated size.
int capacity_
Allocated size of the data_ array.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
void deallocate()
Dellocate the underlying C array.
bool isAllocated() const
Return true if this DArray has been allocated, false otherwise.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.