5#ifndef OILAB_PERIODICFUNCTION_H
6#define OILAB_PERIODICFUNCTION_H
9#include "unsupported/Eigen/CXX11/Tensor"
14 template<
typename Scalar,
int dim>
17 template<
typename Derived,
typename Scalar>
20 template<
typename Scalar,
int dim>
24 const Eigen::Matrix<double,Eigen::Dynamic,dim>
unitCell;
29 const Eigen::Matrix<double,Eigen::Dynamic,dim>& _unitCell);
32 template<
typename T,
typename = T,
typename=T,
int dm=dim,
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,
typename = std::enable_if_t<dm==2>>
39 const Eigen::Matrix<double,Eigen::Dynamic,dim>& _unitCell,
42 template<
typename T,
int dm=dim,
typename = std::enable_if_t<dm==3>>
44 const Eigen::Matrix<double,Eigen::Dynamic,dim>& _unitCell,
55 template<
typename Scalar,
int dim,
typename = std::enable_if_t<dim==2>>
58 auto n = fun.
values.dimensions();
59 assert(n.size() == dim);
60 s << n[0]*n[1] << std::endl;
62 for (
int i = 0; i < n[0]; i++) {
63 for (
int j = 0; j < n[1]; j++) {
64 Eigen::Vector<double, Eigen::Dynamic> x = i * fun.
unitCell.col(0) / n[0] +
66 const Eigen::IOFormat fmt(15, 0,
" ",
"",
" ",
"",
"",
"");
67 s << x.transpose().format(fmt) << std::setw(25) << std::setprecision(15) << fun.
values(i, j)
74 template<
typename Scalar,
int dim,
typename T,
typename = std::enable_if_t<dim==3>>
75 std::basic_ostream<char>&
operator<<(std::basic_ostream<char>& s,
const PeriodicFunction<Scalar, dim>& fun)
77 auto n = fun.values.dimensions();
78 assert(n.size() == dim);
79 s << n[0]*n[1]*n[2] << std::endl;
81 for (
int i = 0; i < n[0]; i++) {
82 for (
int j = 0; j < n[1]; j++) {
83 for (
int k = 0; k < n[2]; k++) {
84 Eigen::Vector<double, Eigen::Dynamic> x = i * fun.unitCell.col(0) / n[0] +
85 j * fun.unitCell.col(1) / n[1] +
86 k * fun.unitCell.col(2) / n[2];
87 const Eigen::IOFormat fmt(15, 0,
" ",
" ",
" ",
"",
"",
"");
88 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)
LatticeFunction< dcomplex, dim > fft() const
Eigen::Tensor< Scalar, dim > values
const Eigen::Matrix< double, Eigen::Dynamic, dim > unitCell
double dot(const PeriodicFunction< Scalar, dim > &other) const
std::complex< double > dcomplex
basic_ostream< char > & operator<<(basic_ostream< char > &s, const LatticeDirection< dim > &m)