TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >

#include <triqs/experimental/lattice/fourier_polynomial.hpp>

Detailed Description

template<int coeff_dim, int kdim>
class triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >

Owning container for a Fourier-series representation of a lattice function.

A fourier_polynomial stores a list of real-space lattice vectors \( \mathbf{R} \) together with their Fourier coefficients and represents the function

\[ f(\mathbf{k}) = \sum_\mathbf{R} f(\mathbf{R}) \, e^{2 \pi i \, \mathbf{k} \cdot \mathbf{R}} \; . \]

It provides a placeholder-aware call operator for CLEF lazy evaluation as well as batched BLAS evaluation at a list of k-points, HDF5 serialization and MPI broadcast.

Template Parameters
coeff_dimRank of the Fourier coefficient at each \( \mathbf{R} \) (e.g. 0 for scalar-, 2 for matrix-valued targets).
kdimDimension of the k-vectors (1, 2 or 3).

Definition at line 188 of file fourier_polynomial.hpp.

Public Member Functions

 fourier_polynomial ()=default
 Default constructor: construct an empty Fourier polynomial.
 fourier_polynomial (fourier_polynomial &&) noexcept=default
 Move constructor.
 fourier_polynomial (fourier_polynomial const &)=default
 Copy constructor.
 fourier_polynomial (std::vector< std::array< long, kdim > > R_list_, nda::array< dcomplex, coeff_dim+1 > coeff_arr_)
 Construct from a list of R-vectors and a packed coefficient array.
 fourier_polynomial (std::vector< std::array< long, kdim > > R_list_, std::vector< nda::array< dcomplex, coeff_dim > > const &coeff_list_)
 Construct from a list of R-vectors and a matching list of coefficient arrays.
auto get_coeff_arr ()
 Get the packed coefficient array.
auto get_coeff_arr () const
 Get the packed coefficient array (const overload).
long get_R_idx (std::array< long, kdim > R) const
 Get the storage index of a given R-vector.
auto const & get_R_list () const
 Get the list of real-space lattice vectors.
auto const & get_R_mat () const
 Get the packed matrix of lattice vectors.
long n_R () const
 Get the number of R-vectors.
nda::array< dcomplex, coeff_dim+1 > operator() (nda::array_const_view< double, 2 > k_list) const
 Evaluate the Fourier polynomial at a batch of k-points given as a matrix.
auto operator() (std::array< double, kdim > ks) const
 Evaluate the Fourier polynomial at a single k-point.
nda::array< dcomplex, coeff_dim+1 > operator() (std::ranges::contiguous_range auto const &k_iterator) const
 Evaluate the Fourier polynomial at a contiguous range of k-points.
template<typename... T>
requires ((std::is_same_v<T, double> or nda::clef::is_lazy<T>) and ...)
auto operator() (T... ks) const
 Evaluate the Fourier polynomial, optionally as a lazy CLEF expression.
fourier_polynomialoperator= (fourier_polynomial &&) noexcept=default
 Move assignment operator.
fourier_polynomialoperator= (fourier_polynomial const &)=default
 Copy assignment operator.
auto operator[] (long i)
 Access the coefficient at a given storage index.
auto operator[] (long i) const
 Access the coefficient at a given storage index (const overload).
auto operator[] (std::array< long, kdim > R)
 Access the coefficient associated with a given R-vector.
auto operator[] (std::array< long, kdim > R) const
 Access the coefficient associated with a given R-vector (const overload).

Static Public Member Functions

static std::string hdf5_format ()
 Get the HDF5 format tag.

Protected Member Functions

void h5_read_impl (h5::group g, std::string const &name, char const *exp_format)
 HDF5 read helper for derived classes: reads R_list and coeff_arr in place; rebuilds R_mat.
void h5_write_impl (h5::group g, std::string const &name, char const *format) const
 HDF5 write helper for derived classes: writes R_list and coeff_arr under the given format tag.

Protected Attributes

nda::array< dcomplex, coeff_dim+1 > coeff_arr
 Packed Fourier coefficients, of shape [nR, coeff_shape...].
std::vector< std::array< long, kdim > > R_list
 Lattice vectors \( \mathbf{R} \) as integer arrays.
nda::matrix< double > R_mat
 Lattice vectors as doubles, of shape [nR, kdim], for BLAS.

Friends

void h5_read (h5::group g, std::string const &name, fourier_polynomial &x)
 Read a Fourier polynomial from HDF5.
void h5_write (h5::group g, std::string const &name, fourier_polynomial const &x)
 Write a Fourier polynomial to HDF5.
void mpi_broadcast (fourier_polynomial &x, mpi::communicator c={}, int root=0)
 Broadcast a Fourier polynomial over an MPI communicator.

Constructor & Destructor Documentation

◆ fourier_polynomial() [1/2]

template<int coeff_dim, int kdim>
triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::fourier_polynomial ( std::vector< std::array< long, kdim > > R_list_,
std::vector< nda::array< dcomplex, coeff_dim > > const & coeff_list_ )
inline

Construct from a list of R-vectors and a matching list of coefficient arrays.

Parameters
R_list_List of lattice vectors \( \mathbf{R} \).
coeff_list_List of Fourier coefficients, one per R-vector and all of the same shape.

Definition at line 231 of file fourier_polynomial.hpp.

◆ fourier_polynomial() [2/2]

template<int coeff_dim, int kdim>
triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::fourier_polynomial ( std::vector< std::array< long, kdim > > R_list_,
nda::array< dcomplex, coeff_dim+1 > coeff_arr_ )
inline

Construct from a list of R-vectors and a packed coefficient array.

Parameters
R_list_List of lattice vectors \( \mathbf{R} \).
coeff_arr_Packed coefficient array of shape [nR, coeff_shape...].

Definition at line 245 of file fourier_polynomial.hpp.

Member Function Documentation

◆ get_coeff_arr() [1/2]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::get_coeff_arr ( )
inlinenodiscard

Get the packed coefficient array.

Returns
View of the packed coefficient array of shape [nR, coeff_shape...].

Definition at line 303 of file fourier_polynomial.hpp.

◆ get_coeff_arr() [2/2]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::get_coeff_arr ( ) const
inlinenodiscard

Get the packed coefficient array (const overload).

Returns
Const view of the packed coefficient array of shape [nR, coeff_shape...].

Definition at line 310 of file fourier_polynomial.hpp.

◆ get_R_idx()

template<int coeff_dim, int kdim>
long triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::get_R_idx ( std::array< long, kdim > R) const
inline

Get the storage index of a given R-vector.

It throws an exception if the R-vector is not present.

Parameters
RLattice vector \( \mathbf{R} \).
Returns
Storage index of R in the list of R-vectors.

Definition at line 366 of file fourier_polynomial.hpp.

◆ get_R_list()

template<int coeff_dim, int kdim>
auto const & triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::get_R_list ( ) const
inlinenodiscard

Get the list of real-space lattice vectors.

Returns
Const reference to the list of lattice vectors \( \mathbf{R} \).

Definition at line 296 of file fourier_polynomial.hpp.

◆ get_R_mat()

template<int coeff_dim, int kdim>
auto const & triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::get_R_mat ( ) const
inlinenodiscard

Get the packed matrix of lattice vectors.

Returns
Const reference to the matrix of lattice vectors of shape [nR, kdim] as doubles.

Definition at line 317 of file fourier_polynomial.hpp.

◆ hdf5_format()

template<int coeff_dim, int kdim>
std::string triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::hdf5_format ( )
inlinestaticnodiscard

Get the HDF5 format tag.

Returns
HDF5 format tag of a Fourier polynomial.

Definition at line 271 of file fourier_polynomial.hpp.

◆ n_R()

template<int coeff_dim, int kdim>
long triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::n_R ( ) const
inlinenodiscard

Get the number of R-vectors.

Returns
Number of lattice vectors stored in the Fourier polynomial.

Definition at line 324 of file fourier_polynomial.hpp.

◆ operator()() [1/4]

template<int coeff_dim, int kdim>
nda::array< dcomplex, coeff_dim+1 > triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator() ( nda::array_const_view< double, 2 > k_list) const
inline

Evaluate the Fourier polynomial at a batch of k-points given as a matrix.

Parameters
k_listMatrix of k-points of shape [nk, kdim].
Returns
Array of shape [nk, coeff_shape...] holding the value at each k-point.

Definition at line 458 of file fourier_polynomial.hpp.

◆ operator()() [2/4]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator() ( std::array< double, kdim > ks) const
inline

Evaluate the Fourier polynomial at a single k-point.

Parameters
ksThe k-point at which to evaluate.
Returns
Value of the Fourier polynomial at ks.

Definition at line 478 of file fourier_polynomial.hpp.

◆ operator()() [3/4]

template<int coeff_dim, int kdim>
nda::array< dcomplex, coeff_dim+1 > triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator() ( std::ranges::contiguous_range auto const & k_iterator) const
inline

Evaluate the Fourier polynomial at a contiguous range of k-points.

Parameters
k_iteratorContiguous range of k-points, each supporting operator[](int).
Returns
Array of shape [nk, coeff_shape...] holding the value at each k-point.

Definition at line 468 of file fourier_polynomial.hpp.

◆ operator()() [4/4]

template<int coeff_dim, int kdim>
template<typename... T>
requires ((std::is_same_v<T, double> or nda::clef::is_lazy<T>) and ...)
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator() ( T... ks) const
inline

Evaluate the Fourier polynomial, optionally as a lazy CLEF expression.

The behavior depends on how many of the arguments are CLEF placeholders (or lazy expressions):

  • With no placeholder, the function is evaluated directly by computing the exponentials.
  • With exactly one placeholder and kdim > 1, a partially evaluated Fourier polynomial of dimension 1 is built and returned as a lazy CLEF call expression.
  • In all other cases (more than one placeholder, or a single placeholder with kdim == 1), a lazy CLEF call expression is returned.
Template Parameters
TArgument types, each either double or a CLEF placeholder / lazy expression.
Parameters
ksThe kdim arguments at which to evaluate, mixing doubles and placeholders.
Returns
The evaluated value if no placeholder is present, otherwise a lazy CLEF call expression.

Definition at line 388 of file fourier_polynomial.hpp.

◆ operator[]() [1/4]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator[] ( long i)
inline

Access the coefficient at a given storage index.

Parameters
iStorage index of the R-vector.
Returns
View of the coefficient at index i.

Definition at line 348 of file fourier_polynomial.hpp.

◆ operator[]() [2/4]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator[] ( long i) const
inline

Access the coefficient at a given storage index (const overload).

Parameters
iStorage index of the R-vector.
Returns
Const view of the coefficient at index i.

Definition at line 356 of file fourier_polynomial.hpp.

◆ operator[]() [3/4]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator[] ( std::array< long, kdim > R)
inline

Access the coefficient associated with a given R-vector.

Parameters
RLattice vector \( \mathbf{R} \).
Returns
View of the coefficient associated with R.

Definition at line 332 of file fourier_polynomial.hpp.

◆ operator[]() [4/4]

template<int coeff_dim, int kdim>
auto triqs::experimental::lattice::fourier_polynomial< coeff_dim, kdim >::operator[] ( std::array< long, kdim > R) const
inline

Access the coefficient associated with a given R-vector (const overload).

Parameters
RLattice vector \( \mathbf{R} \).
Returns
Const view of the coefficient associated with R.

Definition at line 340 of file fourier_polynomial.hpp.

◆ h5_read

template<int coeff_dim, int kdim>
void h5_read ( h5::group g,
std::string const & name,
fourier_polynomial< coeff_dim, kdim > & x )
friend

Read a Fourier polynomial from HDF5.

Parameters
gh5::group to be read from.
nameName of the subgroup.
xFourier polynomial to be read into.

Definition at line 289 of file fourier_polynomial.hpp.

◆ h5_write

template<int coeff_dim, int kdim>
void h5_write ( h5::group g,
std::string const & name,
fourier_polynomial< coeff_dim, kdim > const & x )
friend

Write a Fourier polynomial to HDF5.

Parameters
gh5::group to be written to.
nameName of the subgroup.
xFourier polynomial to be written.

Definition at line 280 of file fourier_polynomial.hpp.

◆ mpi_broadcast

template<int coeff_dim, int kdim>
void mpi_broadcast ( fourier_polynomial< coeff_dim, kdim > & x,
mpi::communicator c = {},
int root = 0 )
friend

Broadcast a Fourier polynomial over an MPI communicator.

The list of R-vectors and the coefficient array are broadcast, and the packed R-matrix is recomputed locally on each rank.

Parameters
xFourier polynomial to broadcast (overwritten on non-root ranks).
cMPI communicator.
rootRank of the broadcasting process.

Definition at line 260 of file fourier_polynomial.hpp.


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