TBTK
|
Need a break? Support the development by playing Polarity Puzzles |
Abstract Property class. More...
#include <AbstractProperty.h>
Public Member Functions | |
unsigned int | getBlockSize () const |
unsigned int | getSize () const |
const std::vector< DataType > & | getData () const |
std::vector< DataType > & | getDataRW () |
unsigned int | getDimensions () const |
std::vector< int > | getRanges () const |
int | getOffset (const Index &index) const |
const IndexDescriptor & | getIndexDescriptor () const |
bool | contains (const Index &index) const |
void | reduce (const std::vector< Index > &targetPatterns, const std::vector< Index > &newPatterns) |
void | hermitianConjugate () |
std::vector< SparseMatrix< DataType > > | toSparseMatrices (const Model &model) const |
virtual const DataType & | operator() (const Index &index, unsigned int offset=0) const |
virtual DataType & | operator() (const Index &index, unsigned int offset=0) |
DataType & | operator() (const std::initializer_list< Subindex > &index) |
const DataType & | operator() (const std::initializer_list< Subindex > &index) const |
virtual const DataType & | operator() (unsigned int offset) const |
virtual DataType & | operator() (unsigned int offset) |
void | setAllowIndexOutOfBoundsAccess (bool allowIndexOutOfBoundsAccess) |
void | setDefaultValue (const DataType &defaultValue) |
void | replaceValues (const DataType &targetValue, const DataType &replacementValue) |
virtual std::string | toString () const |
virtual std::string | serialize (Mode mode) const |
Public Member Functions inherited from TBTK::Serializable | |
template<> | |
std::string | serialize (const bool &data, Mode mode) |
template<> | |
std::string | serialize (const double &data, Mode mode) |
template<> | |
std::string | serialize (const std::complex< double > &data, Mode mode) |
template<> | |
std::string | serialize (const int &data, Mode mode) |
template<> | |
std::string | serialize (const unsigned int &data, Mode mode) |
template<> | |
std::string | serialize (const SpinMatrix &data, Mode mode) |
template<> | |
std::string | serialize (const Statistics &data, Mode mode) |
template<> | |
std::string | serialize (const std::vector< std::complex< double >> &data, Mode mode) |
template<> | |
int | deserialize (const std::string &serialization, Mode mode) |
Protected Member Functions | |
AbstractProperty () | |
AbstractProperty (unsigned int blockSize) | |
AbstractProperty (unsigned int blockSize, const DataType *data) | |
AbstractProperty (const std::vector< int > &ranges, unsigned int blockSize) | |
AbstractProperty (const std::vector< int > &ranges, unsigned int blockSize, const DataType *data) | |
AbstractProperty (const IndexTree &indexTree, unsigned int blockSize) | |
AbstractProperty (const IndexTree &indexTree, unsigned int blockSize, const DataType *data) | |
AbstractProperty (const AbstractProperty &abstractProperty) | |
AbstractProperty (AbstractProperty &&abstractProperty) | |
AbstractProperty (const std::string &serialization, Mode mode) | |
virtual | ~AbstractProperty () |
AbstractProperty & | operator= (const AbstractProperty &abstractProperty) |
AbstractProperty & | operator= (AbstractProperty &&abstractProperty) |
AbstractProperty & | operator+= (const AbstractProperty &rhs) |
AbstractProperty & | operator-= (const AbstractProperty &rhs) |
AbstractProperty & | operator*= (const DataType &rhs) |
AbstractProperty & | operator/= (const DataType &rhs) |
Protected Member Functions inherited from TBTK::Property::Property | |
Property () | |
virtual | ~Property () |
Additional Inherited Members | |
Public Types inherited from TBTK::Serializable | |
enum | Mode { Debug, Binary, XML, JSON } |
Static Public Member Functions inherited from TBTK::Serializable | |
static bool | hasID (const std::string &serialization, Mode mode) |
static std::string | getID (const std::string &serialization, Mode mode) |
static std::string | extractComponent (const std::string &serialization, const std::string &containerID, const std::string &componentID, const std::string &componentName, Mode mode) |
Static Protected Member Functions inherited from TBTK::Serializable | |
static bool | validate (const std::string &serialization, const std::string &id, Mode mode) |
static std::string | getContent (const std::string &serialization, Mode mode) |
static std::vector< std::string > | split (const std::string &content, Mode mode) |
template<typename DataType > | |
static std::enable_if<!std::is_pointer< DataType >::value, std::string >::type | serialize (const DataType &data, Mode mode) |
template<typename DataType > | |
static std::enable_if< std::is_pointer< DataType >::value, std::string >::type | serialize (const DataType &data, Mode mode) |
template<typename DataType > | |
static DataType | deserialize (const std::string &serialization, Mode mode) |
static std::string | extract (const std::string &serialization, Mode mode, std::string component) |
Abstract Property class.
The AbstractProperty provides a generic storage structure for the property classes that inherit from it. For more information about specific Properties, see:
There are three different layers at which the storage structure can be customized to suit the needs for the specific property: the DataType, the block size, and the Index structure.
The DataType determines the data type of the individual data elements.
The data is group into blocks of equal size. It is up to the individual properties to determine the internal structure of these blocks. For example, EnergyResolvedProperties stores the data points for a range of energies in a block, while the Density has a single element per block.
The Index structure determines how blocks are organized and accessed as a function of Indices.
Used for properties that has no Index structure. For example, the DOS.
Used to store properties on a regular grid. It imposes an array like structure on the data that is easy to export to other softwares using, for example, the FileWriter.
Used to store properties for arbitrary combinations of Indices. When the Custom format is used, the data can be accessed using the function notation property(index) or property(index, n). Here index is an Index that selects a block, while n is a number that indexes into the given block.
By default, it is an error to access property(index, n) if the Index index is not included in the property. However, it is possible to configure the property such that out-of-bounds access is allowed. To allow for this we call
The last call specifies the value to return when out-of-bounds access occurs.
It is recommended to not use out-of-bounds access frivolously since out-of-bounds access typically is a sign of an error in the code. Enabling out-of-bounds access can therefore mask faulty behavior.
|
protected |
Constructs an uninitialized AbstractProperty.
|
protected |
Constructs an AbstractProperty with a single data block (i.e. no Index structure).
blockSize | The number of data elements in the block. |
|
protected |
Constructs an AbstractProperty with a single data block (i.e. no Index structure) and fills the internal memory with the data provided as input.
blockSize | The number of data elements in the block. |
data | The data stored on the raw format described in the detailed description of the class. |
|
protected |
Constructs an AbstractProperty with the Ranges format.
ranges | A list of upper limits for the ranges of the different dimensions. The nth dimension will have the range [0, ranges[n]). |
blockSize | The number of data elements per block. |
|
protected |
Constructs an AbstractProperty with the Ranges format and fills the internal memory with the data provided as input.
ranges | A list of upper limits for the ranges of the different dimensions. The nth dimension will have the range [0, ranges[n]). |
blockSize | The number of data elements per block. |
data | The data stored on the raw format described in the detailed description of the class. |
|
protected |
Constructs and AbstractProperty with the Custom format.
indexTree | IndexTree containing the Indices that the AbstractProperty should contain data for. |
blockSize | The number of data elements per block. |
|
protected |
Constructs and AbstractProperty with the Custom format.
indexTree | IndexTree containing the Indices that the AbstractProperty should contain data for. |
blockSize | The number of data elements per block. |
data | The data stored on the raw format described in the detailed description of the class. |
|
protected |
Copy constructor.
abstractProperty | AbstractProperty to copy. |
|
protected |
Move constructor.
abstractProperty | AbstractProperty to move. |
|
inlineprotected |
Constructor. Constructs the AbstractProperty from a serialization string.
serialization | Serialization string from which to construct the AbstractProperty. |
mode | Mode with which the string has been serialized. |
|
inlineprotectedvirtual |
Destructor.
|
inline |
|
inline |
Get block size.
|
inline |
Get data.
|
inline |
Get data. Same as AbstractProperty::getData(), but with write access.
|
inline |
Get the dimension of the data. [Only works for the Ranges format.]
|
inline |
Get IndexDescriptor.
|
inline |
|
inline |
Get the ranges for the dimensions of the density. [Only works for the Ranges format.]
|
inline |
Get size.
|
inline |
|
inlinevirtual |
Function call operator. Returns the data element for the given Index and offset. By default the Property does not accept Indices that are not contained in the Property. However, AbstractProperty::setAllowIndexOutOfBounds(true) is called the Property will return the value set by a call to AbstractProperty::setDefaultVlue(). Note that although it is safe to write to out of bounds elements, doing so does not result in the value being stored in the Property. [Only works for Format::Custom].
index | The Index to get the data for. |
offset | The offset to apply inside the block for the given Index. If not specified, the first element is returned. The function can therefore be used without specifying the offset when Properties with only a single element per block. [Only works for the Custom format.] |
Reimplemented in TBTK::Property::WaveFunctions.
|
inlinevirtual |
Function call operator. Returns the data element for the given Index and offset. By default the Property does not accept Indices that are not contained in the Property. However, AbstractProperty::setAllowIndexOutOfBounds(true) is called the Property will return the value set by a call to AbstractProperty::setDefaultVlue(). [Only works for the Custom format.]
index | The Index to get the data for. |
offset | The offset to apply inside the block for the given Index. If not specified, the first element is returned. The function can therefore be used without specifying the offset when Properties with only a single element per block. [Only works for the Custom format.] |
Reimplemented in TBTK::Property::WaveFunctions.
|
inline |
Alias for operator()(const Index &index, unsigned int offset = 0). Ensures that operator()(unsigned int offset) is not called when calling the function operator default offset and a single subindex index operator()({1}). Without this {1} would be cast to 1 instead of Index({1}).
index | The Index to get the data for. |
|
inline |
Alias for operator()(const Index &index, unsigned int offset = 0). Ensures that operator()(unsigned int offset) is not called when calling the function operator default offset and a single subindex index operator()({1}). Without this {1} would be cast to 1 instead of Index({1}).
index | The Index to get the data for. |
|
inlinevirtual |
Function call operator. Returns the data element for the given offset.
offset | The offset to apply. The offset is an index into the raw data. |
|
inlinevirtual |
Alias for operator()(const Index &index, unsigned int offset = 0). Ensures that operator()(unsigned int offset) is not called when calling the function operator default offset and a single subindex index operator()({1}). Without this {1} would be cast to 1 instead of Index({1}).
index | The Index to get the data for. |
index | The Index to get the data for. |
offset | The offset to apply. The offset is an index into the raw data. |
|
inlineprotected |
Multiplication assignment operator. Child classes that want to use this function must override this function and call the parents multiplication assignment operator after having performed checks whether the multiplication is possible, and before performing the multiplication of the child class parameters.
The | value to multiply the left hand side by. |
|
inlineprotected |
Addition assignment operator. Child classes that want to use this function must override this function and call the parents addition assignment operator after having performed checks whether the addition is possible, and before performing the addition of the child class parameters.
The | AbstractProperty to be added to the left hand side. |
|
inlineprotected |
Subtraction assignment operator. Child classes that want to use this function must override this function and call the parents subtraction assignment operator after having performed checks whether the subtraction is possible, and before performing the subtraction of the child class parameters.
The | AbstractProperty to be subtracted from the left hand side. |
|
inlineprotected |
Division assignment operator. Child classes that want to use this function must override this function and call the parents division assignment operator after having performed checks whether the division is possible, and before performing the division of the child class parameters.
The | value to divide the left hand side by. |
|
protected |
Move assignment operator.
rhs | AbstractProperty to assign to the left hand side. |
|
protected |
Assignment operator.
rhs | AbstractProperty to assign to the left hand side. |
|
inline |
Reduces the size of the Property by only keeping values for indices that match the given target patterns. If a matching target pattern exists for a given value, the value will be stored with an Index that matches a corresponding new pattern. E.g., assume the target patterns are { {0, IDX_ALL_0, IDX_ALL_1, IDX_ALL_1}, {1, IDX_ALL_0, IDX_ALL_0} } and the new patterns are { {0, IDX_ALL_0, IDX_ALL_1}, {1, IDX_ALL_0} }. Then the data for indices such as {0, 1, 2, 3} and {1, 2, 3} will be droped since the two last subindices are not the same, which is required by both of the target patterns. However, the data for the indices {0, 1, 2, 2} and {1, 2, 2} will be kept and available through the new indices {0, 1, 2} and {1, 2}, respectively. More specifically, {0, 1, 2, 2} match the first pattern and {1, 2, 2} matches the second pattern. {0, 1, 2, 3} is therefore kept and transformed to the form {0, IDX_ALL_0, IDX_ALL_1}, while {1, 2, 2} is kept and transformed to the form {1, IDX_ALL_0}.
targetPatterns | List of patterns for indices to keep. |
newPatterns | List of new patterns to convert the preserved indices to. |
|
inline |
Replace all values with a given target value by a given replacement value. Can be used to for example replace NaN and inf by finite numbers.
targetValue | The value to replace. |
replacementValue. | The value to replace with. |
|
inlinevirtual |
Implements Serializable::serialize().
Implements TBTK::Serializable.
Reimplemented in TBTK::Property::EnergyResolvedProperty< DataType >, TBTK::Property::EnergyResolvedProperty< SpinMatrix >, TBTK::Property::EnergyResolvedProperty< double >, TBTK::Property::EnergyResolvedProperty< std::complex< double > >, TBTK::Property::LDOS, TBTK::Property::Density, TBTK::Property::DOS, TBTK::Property::SpinPolarizedLDOS, TBTK::Property::EigenValues, TBTK::Property::WaveFunctions, and TBTK::Property::Magnetization.
|
inline |
Set whether the access of data elements for Indices that are not contained in the Property is allowed or not when using the function operator AbstractProperty::operator(). If enabled, remember to also initialize the value that is used for out of bounds access using AbstractProperty::setDefaultValue(). [Only meaningful for the Custom format.]
allowIndexOutOfBoundsAccess | True to enable out of bounds access. |
|
inline |
Set the value that is returned when accessing indices not contained in the Property using the function operator AbstractProperty::operator(). Only used if AbstractProperty::setAllowIndexOutOfBoundsAccess(true) is called. [Only meaningful for the Custom format.]
defaultValue | The value that will be returned for out of bounds access. |
|
inline |
Converts the matrix to a set of SparseMatrices . This only works for Properties on the Format::Custom. In addition, the Index structure has to be such that every Index is a composit Index with exactly two component Indices.
model | A model that determines the maping from the physical indices in the Property and the linear indices in the matrix representation. |
|
inlinevirtual |
Implements Serializable::toString().
Implements TBTK::Streamable.