TBTK
|
Need a break? Support the development by playing Polarity Puzzles |
Exports data on human readable format. More...
#include <Exporter.h>
Public Types | |
enum | Format { RowMajor, ColumnMajor } |
Public Member Functions | |
Exporter () | |
template<typename DataType > | |
void | save (const Property::AbstractProperty< DataType > &abstractProperty, const std::string &filename) const |
template<typename DataType > | |
void | save (const Property::AbstractProperty< DataType > &abstractProperty, const Index &pattern, const std::string &filename) const |
template<typename DataType > | |
void | save (const Array< DataType > &array, const std::string &filename) const |
void | setFormat (Format format) |
Exports data on human readable format.
The Exporter can write Arrays and Properties to file.
By default, the data is written to file on row major order. This means that the right most Subindex increments the fastest, while the left most subindex changes the slowest. For Properties with a block structure, the intra block index should be understood as standing to the right of any Index. Similarly, any data type with indexable internal structure should be understood as having its indices to the right of any Index and intra block index.
For example, assume the property has index structure {x, y}, a block index n, and data type std::complexa<double>. The total index structure can then be thought of as being {x, y, n, c}, where c=0 and c=1 corresponds to real and imaginary part, respectively. If the dimensions are given by {SIZE_X, SIZE_Y, BLOCK_SIZE, 2}, the element order is given by
Languages such as Fortran and MATLAB use column major order. To simplify import to such languages, it is also possible to export the data on column major order. To do so, set the format to column major before exporting the data.
Arrays are exported as follows
Properties that are on the formats IndexDescriptor::Format::None and IndexDescriptor::Format::Ranges can be exported as follows.
Properties that are on the format IndexDescriptor::Format::Custom can be exported as follows.
Here it is assumed that property has the index structure {x, y, z} and that the data for all indices satisfying the pattern {x, 5, z}. are to be exported.
Below we demonstrate how to export data to other languages. The example is for a density with the index structure {x, y, z} and with the number of elements for the corresponding dimensions being {SIZE_X, SIZE_Y, SIZE_Z}.
|
strong |
Enum class for
|
inline |
Default constructor.
void TBTK::Exporter::save | ( | const Array< DataType > & | array, |
const std::string & | filename | ||
) | const |
void TBTK::Exporter::save | ( | const Property::AbstractProperty< DataType > & | abstractProperty, |
const Index & | pattern, | ||
const std::string & | filename | ||
) | const |
void TBTK::Exporter::save | ( | const Property::AbstractProperty< DataType > & | abstractProperty, |
const std::string & | filename | ||
) | const |
|
inline |
Set the output format. The default value is Format::RowMajor
format | The output format to use. |