5#ifndef OILAB_PERIODICFUNCTION_H
6#define OILAB_PERIODICFUNCTION_H
9#include "unsupported/Eigen/CXX11/Tensor"
16template <
typename Derived,
typename Scalar>
class Function;
21 const Eigen::Matrix<double, Eigen::Dynamic, dim>
unitCell;
26 const Eigen::array<Eigen::Index, dim> &n,
27 const Eigen::Matrix<double, Eigen::Dynamic, dim> &_unitCell);
31 template <
typename T,
typename = T,
typename = T,
int dm = dim,
32 typename = std::enable_if_t<dm == 1>>
34 const Eigen::Matrix<double, Eigen::Dynamic, dim> &_unitCell,
37 template <
typename T,
typename = T,
int dm = dim,
38 typename = std::enable_if_t<dm == 2>>
40 const Eigen::Matrix<double, Eigen::Dynamic, dim> &_unitCell,
43 template <
typename T,
int dm = dim,
typename = std::enable_if_t<dm == 3>>
45 const Eigen::Matrix<double, Eigen::Dynamic, dim> &_unitCell,
57 template<
typename Scalar,
int dim,
typename = std::enable_if_t<dim==2>>
60 auto n = fun.
values.dimensions();
61 assert(n.size() == dim);
62 s << n[0]*n[1] << std::endl;
64 for (
int i = 0; i < n[0]; i++) {
65 for (
int j = 0; j < n[1]; j++) {
66 Eigen::Vector<double, Eigen::Dynamic> x = i * fun.
unitCell.col(0) / n[0] +
68 const Eigen::IOFormat fmt(15, 0,
" ",
"",
" ",
"",
"",
"");
69 s << x.transpose().format(fmt) << std::setw(25) << std::setprecision(15) << fun.
values(i, j)
76 template<
typename Scalar,
int dim,
typename T,
typename = std::enable_if_t<dim==3>>
77 std::basic_ostream<char>&
operator<<(std::basic_ostream<char>& s,
const PeriodicFunction<Scalar, dim>& fun)
79 auto n = fun.values.dimensions();
80 assert(n.size() == dim);
81 s << n[0]*n[1]*n[2] << std::endl;
83 for (
int i = 0; i < n[0]; i++) {
84 for (
int j = 0; j < n[1]; j++) {
85 for (
int k = 0; k < n[2]; k++) {
86 Eigen::Vector<double, Eigen::Dynamic> x = i * fun.unitCell.col(0) / n[0] +
87 j * fun.unitCell.col(1) / n[1] +
88 k * fun.unitCell.col(2) / n[2];
89 const Eigen::IOFormat fmt(15, 0,
" ",
" ",
" ",
"",
"",
"");
90 s << x.transpose().format(fmt) << std::setw(25) << std::setprecision(15) << fun.values(i,j,k)
PeriodicFunction< Scalar, dim > kernelConvolution(const Function< T, Scalar > &kernel)
Eigen::Tensor< Scalar, dim > values
const Eigen::Matrix< double, Eigen::Dynamic, dim > unitCell
double dot(const PeriodicFunction< Scalar, dim > &other) const
LatticeFunction< dcomplex, dim > fft() const
std::complex< double > dcomplex
basic_ostream< char > & operator<<(basic_ostream< char > &s, const LatticeDirection< dim > &m)