NanoStructures
1.0
DMFT solver for layered, strongly correlated nanostructures
|
Discretized complex-valued function for real arguments. More...
#include <cfunction.h>
Public Types | |
typedef std::complex< double >(* | tIntegrandFunction )(double, std::complex< double >, void *) |
Public Member Functions | |
CFunction () | |
empty, default constructor | |
CFunction (int length) | |
allocates an instance for length data points. More... | |
CFunction (const CFunction &orig) | |
copy constructor More... | |
CFunction & | operator= (const CFunction &orig) |
operator= More... | |
virtual | ~CFunction () |
destructor frees all previously allocated memory. | |
void | resize (int length) |
changes the size of the storage container to hold length argument-value pairs. More... | |
int | getSize () const |
returns current size of the storage container More... | |
void | set (int index, double argument, std::complex< double > value) |
sets the datapoint with indicated index. More... | |
void | setArgument (int index, double argument) |
sets argument of the argument-value pair with index index to argument More... | |
void | setValue (int index, std::complex< double > value) |
sets value of the argument-value pair with index index to value More... | |
double | getArgument (int index) const |
returns the argument of the pair with index index. More... | |
std::complex< double > | getValue (int index) const |
returns the value of the pair with index index. More... | |
double | getValueReal (int index) const |
returns the value's real part of the pair with index index. More... | |
double | getValueImag (int index) const |
returns the value's imaginary part of the pair with index index. More... | |
void | write (std::string filename) const |
writes the data of the instance as a text file named filename. More... | |
void | read (std::string filename) |
reads data from the text file named filename. More... | |
void | writeBinary (std::string filename) const |
writes the data of the instance as a binary file named filename. More... | |
void | readBinary (std::string filename) |
reads data to the instance as a binary file named filename. More... | |
void | dump () const |
dumps the data of the instance to std::cout. | |
void | rescale (double factor) |
multiplies all arguments and values by the factor factor. More... | |
bool | operator== (const CFunction &rhs) const |
compares the current instance to the instance rhs More... | |
void | createLogGrid (double maxFrequency, double lambda, int n) |
creates a logarithmic grid in argument space about 0. More... | |
math::CFunction | transformPH () const |
std::complex< double > | interpolate (double x) |
finds the linear interpolation of the discretized function at x. More... | |
math::CFunction | interpolate (double x1, double x2) const |
math::CFunction | interpolate (double x1, double x2, std::complex< double > C1, std::complex< double > C2, std::complex< double > D1, std::complex< double > D2) const |
std::complex< double > | integrate (double x_1, double x_2) const |
std::complex< double > | integrate (double x_1, double x_2, tIntegrandFunction g, void *parameters) const |
Protected Attributes | |
double * | m_arguments |
std::complex< double > * | m_values |
int | m_length |
Friends | |
class | PFunction |
class | mpi::OpenMPI |
math::CFunction | operator* (std::complex< double > factor, const math::CFunction &f) |
math::CFunction | operator/ (const math::CFunction &f, const math::CFunction &g) |
math::CFunction | operator+ (const math::CFunction &f, const math::CFunction &g) |
math::CFunction | operator/ (const math::CFunction &f, double denominator) |
Discretized complex-valued function for real arguments.
The arguments should be added in ascending order. It is the programmer's job to ensure this.
math::CFunction::CFunction | ( | int | length | ) |
allocates an instance for length data points.
length | # of data points |
math::CFunction::CFunction | ( | const CFunction & | orig | ) |
copy constructor
[in] | orig | reference to original instance |
void math::CFunction::createLogGrid | ( | double | maxFrequency, |
double | lambda, | ||
int | n | ||
) |
creates a logarithmic grid in argument space about 0.
This function creates a function with \(n\) argument-value pairs with arguments \(-A \lambda^0, -A \lambda^1, \dots, -A \lambda^{-n/2},A \lambda^{-n/2},\dots,A \lambda^1,A \lambda^0\). If \(n%2==1\) an additional datapoint with argument 0 is created. The values are initialized with 0's.
[in] | maxFrequency | maximum frequency |
[in] | lambda | discretization parameter |
[in] | n | # of datapoints |
double math::CFunction::getArgument | ( | int | index | ) | const |
returns the argument of the pair with index index.
[in] | index | index of name-value pair |
|
inline |
returns current size of the storage container
std::complex< double > math::CFunction::getValue | ( | int | index | ) | const |
returns the value of the pair with index index.
[in] | index | index of name-value pair |
double math::CFunction::getValueImag | ( | int | index | ) | const |
returns the value's imaginary part of the pair with index index.
[in] | index | index of name-value pair |
double math::CFunction::getValueReal | ( | int | index | ) | const |
returns the value's real part of the pair with index index.
[in] | index | index of name-value pair |
std::complex< double > math::CFunction::interpolate | ( | double | x | ) |
finds the linear interpolation of the discretized function at x.
If x lies outside the range of arguments, the function throws an error::math::OutOfBounds exception.
[in] | x | interpolation point |
operator=
[in] | orig | reference to original instance |
bool math::CFunction::operator== | ( | const CFunction & | rhs | ) | const |
compares the current instance to the instance rhs
This function returns true if the # of argument-value pairs and all arguments and values of the two instances coincide.
[in] | rhs | instance to compare to |
void math::CFunction::read | ( | std::string | filename | ) |
reads data from the text file named filename.
Every line of the file should contain an argument-value pair with a space as a separator. The size of the storage container is adjusted. All previous data is discarded.
[in] | filename | filename for the written file |
void math::CFunction::readBinary | ( | std::string | filename | ) |
reads data to the instance as a binary file named filename.
The first integer in the file should denote the # of name-value pairs. The size of the storage container is adjusted. All previous data is discarded.
filename | filename for the written file |
void math::CFunction::rescale | ( | double | factor | ) |
multiplies all arguments and values by the factor factor.
factor | scaling factor |
void math::CFunction::resize | ( | int | length | ) |
changes the size of the storage container to hold length argument-value pairs.
All previous data is discarded.
[in] | length | new size of the storage container. |
void math::CFunction::set | ( | int | index, |
double | argument, | ||
std::complex< double > | value | ||
) |
sets the datapoint with indicated index.
The function sets argument of the argument-value pair with index index to argument and value value.
[in] | index | index of name-value pair |
[in] | argument | new argument |
value | new value |
void math::CFunction::setArgument | ( | int | index, |
double | argument | ||
) |
sets argument of the argument-value pair with index index to argument
[in] | index | index of name-value pair |
[in] | argument | new argument |
void math::CFunction::setValue | ( | int | index, |
std::complex< double > | value | ||
) |
sets value of the argument-value pair with index index to value
[in] | index | index of argument-value pair |
[in] | value | new value |
void math::CFunction::write | ( | std::string | filename | ) | const |
writes the data of the instance as a text file named filename.
Every line of the file contains an argument-value pair with a space as a separator.
[in] | filename | filename for the written file |
void math::CFunction::writeBinary | ( | std::string | filename | ) | const |
writes the data of the instance as a binary file named filename.
The first integer in the file denotes the # of name-value pairs.
filename | filename for the written file |