PSCF v1.1
Public Member Functions | Protected Attributes | List of all members
Pscf::Pspc::Field< Data > Class Template Reference

Dynamic array with aligned data, for use with FFTW library. More...

#include <Field.h>

Public Member Functions

 Field ()
 Default constructor. More...
 
virtual ~Field ()
 Destructor. More...
 
void allocate (int capacity)
 Allocate the underlying C array. More...
 
void deallocate ()
 Dellocate the underlying C array. More...
 
bool isAllocated () const
 Return true if the Field has been allocated, false otherwise. More...
 
int capacity () const
 Return allocated size. More...
 
Data & operator[] (int i)
 Get an element by non-const reference. More...
 
Data const & operator[] (int i) const
 Get an element by const reference. More...
 
Data * cField ()
 Return pointer to underlying C array. More...
 
Data const * cField () const
 Return pointer to const to underlying C array. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize a Field to/from an Archive. More...
 

Protected Attributes

Data * data_
 Pointer to an array of Data elements. More...
 
int capacity_
 Allocated size of the data_ array. More...
 

Detailed Description

template<typename Data>
class Pscf::Pspc::Field< Data >

Dynamic array with aligned data, for use with FFTW library.

Definition at line 25 of file pspc/field/Field.h.

Constructor & Destructor Documentation

◆ Field()

template<typename Data >
Pscf::Pspc::Field< Data >::Field ( )

Default constructor.

References Pscf::Pspc::Field< Data >::cField().

◆ ~Field()

template<typename Data >
Pscf::Pspc::Field< Data >::~Field ( )
virtual

Destructor.

Deletes underlying C array, if allocated previously.

Definition at line 35 of file Field.tpp.

Member Function Documentation

◆ allocate()

template<typename Data >
void Pscf::Pspc::Field< Data >::allocate ( int  capacity)

Allocate the underlying C array.

Exceptions
Exceptionif the Field is already allocated.
Parameters
capacitynumber of elements to allocate.

Definition at line 51 of file Field.tpp.

References UTIL_THROW.

Referenced by Pscf::Pspc::RField< D >::allocate(), and Pscf::Pspc::RFieldDft< D >::allocate().

◆ deallocate()

template<typename Data >
void Pscf::Pspc::Field< Data >::deallocate ( )

Dellocate the underlying C array.

Exceptions
Exceptionif the Field is not allocated.

Definition at line 69 of file Field.tpp.

References UTIL_THROW.

◆ isAllocated()

template<typename Data >
bool Pscf::Pspc::Field< Data >::isAllocated ( ) const
inline

Return true if the Field has been allocated, false otherwise.

Definition at line 181 of file pspc/field/Field.h.

◆ capacity()

template<typename Data >
int Pscf::Pspc::Field< Data >::capacity ( ) const
inline

Return allocated size.

Returns
Number of elements allocated in array.

Definition at line 135 of file pspc/field/Field.h.

◆ operator[]() [1/2]

template<typename Data >
Data & Pscf::Pspc::Field< Data >::operator[] ( int  i)
inline

Get an element by non-const reference.

Mimic C-array subscripting.

Parameters
iarray index
Returns
non-const reference to element i

Definition at line 142 of file pspc/field/Field.h.

◆ operator[]() [2/2]

template<typename Data >
Data const & Pscf::Pspc::Field< Data >::operator[] ( int  i) const
inline

Get an element by const reference.

Mimics C-array subscripting.

Parameters
iarray index
Returns
const reference to element i

Definition at line 154 of file pspc/field/Field.h.

◆ cField() [1/2]

template<typename Data >
Data * Pscf::Pspc::Field< Data >::cField ( )
inline

Return pointer to underlying C array.

Definition at line 166 of file pspc/field/Field.h.

Referenced by Pscf::Pspc::Field< Data >::Field().

◆ cField() [2/2]

template<typename Data >
Data const * Pscf::Pspc::Field< Data >::cField ( ) const
inline

Return pointer to const to underlying C array.

Definition at line 174 of file pspc/field/Field.h.

◆ serialize()

template<typename Data >
template<class Archive >
void Pscf::Pspc::Field< Data >::serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize a Field to/from an Archive.

Parameters
ararchive
versionarchive version id

Referenced by Pscf::Pspc::RField< D >::serialize(), and Pscf::Pspc::RFieldDft< D >::serialize().

Member Data Documentation

◆ data_

template<typename Data >
Data* Pscf::Pspc::Field< Data >::data_
protected

Pointer to an array of Data elements.

Definition at line 112 of file pspc/field/Field.h.

◆ capacity_

template<typename Data >
int Pscf::Pspc::Field< Data >::capacity_
protected

Allocated size of the data_ array.

Definition at line 115 of file pspc/field/Field.h.


The documentation for this class was generated from the following files: