32#ifndef MADNESS_MRA_CONVOLUTION1D_H__INCLUDED
33#define MADNESS_MRA_CONVOLUTION1D_H__INCLUDED
61 for (
long i=0; i<n; ++i, out+=
ldout, in+=
ldin) {
62 for (
long j=0; j<
m; ++j) {
81 for (
long i=0; i<
nm; ++i)
b[i] =
a[i];
88 for (
long i=0; i<
n4; i+=4, a0+=
m4) {
93 for (
long j=0; j<
m; ++j,
bi+=n) {
106 for (
long i=
n4; i<n; ++i)
107 for (
long j=0; j<
m; ++j)
161 template <
typename Q>
191 for (
int i=0; i<
k; ++i)
192 for (
int j=0; j<
k; ++j)
233 for (
int i=0; i<n; ++i) {
234 for (
int j=0; j<n; ++j) {
238 for (
int i=n-1; i>1; --i) {
245 for (
int i=0; i<n; ++i) {
257 template <
typename Q>
387 R.scale(
pow(0.5,0.5*n));
532 if constexpr (std::is_arithmetic_v<Q>)
583 template <
typename Q,
int NDIM>
585 std::array<std::shared_ptr<Convolution1D<Q> >,
NDIM>
ops;
598 std::fill(
ops.begin(),
ops.end(),
op);
605 std::shared_ptr<Convolution1D<Q> >
getop(
int dim)
const {
620 for (
int d = 0;
d !=
NDIM; ++
d) {
622 result[
d] =
ops[
d]->lattice_summed();
629 template <
typename Q>
655 template <
typename Q,
typename opT>
699 double fac = std::pow(0.5,
n);
710 return adq1(lx, lx+1,
Shmoo(n, lx,
this), 1
e-12,
715 if (lx < 0) lx = 1 - lx;
718 if (lx <= 7)
return false;
721 if (n >= 0) lx = lx << n;
733 template <
typename Q>
756 int m,
bool periodic,
double bloch_k = 0.0,
798 int twok = 2*this->
k;
828 const auto L =
x1 -
x0;
862 double fourn = std::pow(4.0,
double(n));
936 const auto x = xx *
pow(0.5,
double(n));
959 for (
long p = 0;
p <
twok; ++
p)
978 const auto ll = lx - 1;
981 const auto ll = lx + 1;
989 template <
typename Q>
995 static std::shared_ptr< GaussianConvolution1D<Q> >
get(
int k,
double expnt,
int m,
bool periodic,
996 double bloch_k = 0.0,
1009 if (it ==
map.end()) {
1025 auto& result = it->second;
1029 result->lattice_summed() == periodic &&
1030 result->range == range &&
1031 result->bloch_k == bloch_k);
Provides routines for internal use optimized for aligned data.
std::complex< double > double_complex
Definition cfft.h:14
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
Definition worldhashmap.h:396
Provides the common functionality/interface of all 1D convolutions.
Definition convolution1d.h:258
SimpleCache< Tensor< Q >, 1 > rnlp_cache
Definition convolution1d.h:272
Tensor< double > hgT2k
Definition convolution1d.h:270
virtual Level natural_level() const
Returns the level for projection.
Definition convolution1d.h:364
bool lattice_summed() const
Definition convolution1d.h:277
int maxR
Number of lattice translations for sum.
Definition convolution1d.h:263
Tensor< double > hg
Definition convolution1d.h:269
int k
Wavelet order.
Definition convolution1d.h:261
SimpleCache< ConvolutionData1D< Q >, 1 > ns_cache
Definition convolution1d.h:274
Tensor< double > hgT
Definition convolution1d.h:269
Tensor< double > c
Definition convolution1d.h:268
double bloch_k
k in exp(i k R) Bloch phase factor folded into lattice sum
Definition convolution1d.h:264
const Tensor< Q > & get_rnlp(Level n, Translation lx) const
Definition convolution1d.h:539
bool rnlp_is_zero(Level n, Translation l) const
Definition convolution1d.h:344
SimpleCache< Tensor< Q >, 1 > rnlij_cache
Definition convolution1d.h:273
virtual Tensor< Q > rnlp(Level n, Translation lx) const =0
Compute the projection of the operator onto the double order polynomials.
Convolution1D(int k, int npt, int maxR, double bloch_k=0.0, KernelRange rng={})
Definition convolution1d.h:282
bool range_restricted() const
Definition convolution1d.h:278
int npt
Number of quadrature points (is this used?)
Definition convolution1d.h:262
KernelRange range
if range is nonnull, kernel range limited to to range (in simulation cell units), useful for finite-r...
Definition convolution1d.h:265
virtual ~Convolution1D()
Definition convolution1d.h:280
Tensor< double > quad_w
Definition convolution1d.h:267
Q phase(double R) const
Definition convolution1d.h:531
SimpleCache< ConvolutionData1D< Q >, 2 > mod_ns_cache
Definition convolution1d.h:275
bool get_issmall(Level n, Translation lx) const
Definition convolution1d.h:317
Tensor< double > quad_x
Definition convolution1d.h:266
const Tensor< Q > & rnlij(Level n, Translation lx, bool do_transpose=false) const
Computes the transition matrix elements for the convolution for n,l.
Definition convolution1d.h:376
virtual bool issmall(Level n, Translation lx) const =0
const ConvolutionData1D< Q > * mod_nonstandard(const Key< 2 > &op_key) const
Returns a pointer to the cached modified make_nonstandard form of the operator.
Definition convolution1d.h:399
Q opT
The apply function uses this to infer resultT=opT*inputT.
Definition convolution1d.h:260
const ConvolutionData1D< Q > * nonstandard(Level n, Translation lx) const
Returns a pointer to the cached make_nonstandard form of the operator.
Definition convolution1d.h:466
Array of 1D convolutions (one / dimension)
Definition convolution1d.h:584
std::shared_ptr< Convolution1D< Q > > getop(int dim) const
Definition convolution1d.h:605
void setop(int dim, const std::shared_ptr< Convolution1D< Q > > &op)
Definition convolution1d.h:601
ConvolutionND(const ConvolutionND &other)
Definition convolution1d.h:591
ConvolutionND()
Definition convolution1d.h:589
std::array< std::shared_ptr< Convolution1D< Q > >, NDIM > ops
Definition convolution1d.h:585
Q fac
Definition convolution1d.h:586
ConvolutionND(std::shared_ptr< Convolution1D< Q > > op, Q fac=1.0)
Definition convolution1d.h:596
Q getfac() const
Definition convolution1d.h:613
array_of_bools< NDIM > lattice_summed() const
Definition convolution1d.h:618
void setfac(Q value)
Definition convolution1d.h:609
1D convolution with (derivative) Gaussian; coeff and expnt given in simulation coordinates [0,...
Definition convolution1d.h:734
const int m
Order of derivative (0, 1, or 2 only)
Definition convolution1d.h:753
Tensor< Q > rnlp(Level n, const Translation lx) const final
Compute the projection of the operator onto the double order polynomials.
Definition convolution1d.h:797
GaussianConvolution1D(int k, Q coeff, double expnt, int m, bool periodic, double bloch_k=0.0, KernelRange rng={})
Definition convolution1d.h:755
virtual ~GaussianConvolution1D()
Definition convolution1d.h:774
const double expnt
Exponent.
Definition convolution1d.h:751
const Level natlev
Level to evaluate.
Definition convolution1d.h:752
static int maxR(bool periodic, double expnt, const KernelRange &rng={})
Definition convolution1d.h:737
const Q coeff
Coefficient.
Definition convolution1d.h:750
bool issmall(Level n, Translation lx) const final
Definition convolution1d.h:967
virtual Level natural_level() const final
Returns the level for projection.
Definition convolution1d.h:776
Definition convolution1d.h:630
Q coeff
Definition convolution1d.h:632
int m
Definition convolution1d.h:634
Level natural_level() const
Definition convolution1d.h:648
Level natlev
Definition convolution1d.h:635
GaussianGenericFunctor(Q coeff, double exponent, int m=0)
Definition convolution1d.h:639
Q operator()(double x) const
Definition convolution1d.h:643
double exponent
Definition convolution1d.h:633
Generic 1D convolution using brute force (i.e., slow) adaptive quadrature for rnlp.
Definition convolution1d.h:656
bool issmall(Level n, Translation lx) const final
Definition convolution1d.h:714
GenericConvolution1D(int k, const opT &op, int maxR, double bloch_k=0.0)
Definition convolution1d.h:664
opT op
Definition convolution1d.h:658
Tensor< Q > rnlp(Level n, Translation lx) const final
Compute the projection of the operator onto the double order polynomials.
Definition convolution1d.h:709
virtual Level natural_level() const final
Returns the level for projection.
Definition convolution1d.h:686
long maxl
At natural level is l beyond which operator is zero.
Definition convolution1d.h:659
GenericConvolution1D()
Definition convolution1d.h:662
Definition kernelrange.h:19
bool finite_soft() const
Definition kernelrange.h:118
double sigma() const
Definition kernelrange.h:111
int iextent_x2(double epsilon=extent_default_epsilon) const
Definition kernelrange.h:157
bool finite() const
Definition kernelrange.h:114
unsigned int N() const
Definition kernelrange.h:109
double value(double r) const
Definition kernelrange.h:135
bool finite_hard() const
Definition kernelrange.h:116
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:68
Simplified interface around hash_map to cache stuff for 1D.
Definition simplecache.h:46
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimensional array.
Definition tensor.h:317
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1726
TensorTypeData< T >::scalar_type scalar_type
C++ typename of the real type associated with a complex type.
Definition tensor.h:409
T * ptr()
Returns a pointer to the internal data.
Definition tensor.h:1824
Tensor< T > & gaxpy(T alpha, const Tensor< T > &t, T beta)
Inplace generalized saxpy ... this = this*alpha + other*beta.
Definition tensor.h:1804
A simple, fixed dimension vector.
Definition vector.h:64
syntactic sugar for std::array<bool, N>
Definition array_of_bools.h:19
Defines common mathematical and physical constants.
static const double R
Definition csqrt.cc:46
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
const double beta
Definition gygi_soltion.cc:62
static const double v
Definition hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
static double pow(const double *a, const double *b)
Definition lda.h:74
#define max(a, b)
Definition lda.h:51
#define final(a, b, c)
Definition lookup3.c:153
#define MADNESS_PRAGMA_CLANG(x)
Definition madness_config.h:200
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
constexpr double pi
Mathematical constant .
Definition constants.h:48
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
bool two_scale_hg(int k, Tensor< double > *hg)
Definition twoscale.cc:151
void aligned_add(long n, double *MADNESS_RESTRICT a, const double *MADNESS_RESTRICT b)
void fast_transpose(long n, long m, const T *a, T *MADNESS_RESTRICT b)
a(n,m) --> b(m,n) ... optimized for smallish matrices
Definition convolution1d.h:70
void legendre_scaling_functions(double x, long k, double *p)
Evaluate the first k Legendre scaling functions.
Definition legendre.cc:85
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:689
response_space transpose(response_space &f)
Definition basic_operators.cc:10
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:260
int64_t Translation
Definition key.h:56
int Level
Definition key.h:57
static void copy_2d_patch(T *MADNESS_RESTRICT out, long ldout, const T *MADNESS_RESTRICT in, long ldin, long n, long m)
Definition convolution1d.h:60
bool autoc(int k, Tensor< double > *c)
Return the autocorrelation coefficients for scaling functions of given order.
Definition twoscale.cc:234
bool gauss_legendre(int n, double xlo, double xhi, double *x, double *w)
Definition legendre.cc:226
static double pop(std::vector< double > &v)
Definition SCF.cc:113
void svd(const Tensor< T > &a, Tensor< T > &U, Tensor< typename Tensor< T >::scalar_type > &s, Tensor< T > &VT)
Compute the singluar value decomposition of an n-by-m matrix using *gesvd.
Definition lapack.cc:739
NDIM & f
Definition mra.h:2448
std::size_t hashT
The hash value type.
Definition worldhash.h:145
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
void aligned_sub(long n, double *MADNESS_RESTRICT a, const double *MADNESS_RESTRICT b)
funcT::returnT adq1(double lo, double hi, const funcT &func, double thresh, int n, const double *x, const double *w, int level)
Definition adquad.h:64
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:284
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition array_addons.h:78
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2034
static long abs(long a)
Definition tensor.h:218
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
double Q(double a)
Definition relops.cc:20
static const double m
Definition relops.cc:9
static const double L
Definition rk.cc:46
static const long k
Definition rk.cc:44
!!! Note that if Rnormf is zero then ALL of the tensors are empty
Definition convolution1d.h:162
Tensor< Q > T
if NS: R=ns, T=T part of ns; if modified NS: T=\uparrow r^(n-1)
Definition convolution1d.h:165
double Rnorm
Definition convolution1d.h:170
Tensor< typename Tensor< Q >::scalar_type > Rs
Definition convolution1d.h:167
void make_approx(const Tensor< Q > &R, Tensor< Q > &RU, Tensor< typename Tensor< Q >::scalar_type > &Rs, Tensor< Q > &RVT, double &norm)
Definition convolution1d.h:229
double N_up
Definition convolution1d.h:173
double NSnormf
Definition convolution1d.h:170
double Rnormf
Definition convolution1d.h:170
Tensor< Q > TU
Definition convolution1d.h:166
ConvolutionData1D(const Tensor< Q > &R, const Tensor< Q > &T)
Definition convolution1d.h:180
double N_F
the norms according to Beylkin 2008, Eq. (21) ff
Definition convolution1d.h:173
double N_diff
Definition convolution1d.h:173
Tensor< Q > RU
Definition convolution1d.h:166
double Tnorm
Definition convolution1d.h:170
Tensor< typename Tensor< Q >::scalar_type > Ts
hold relative errors, NOT the singular values..
Definition convolution1d.h:167
ConvolutionData1D(const Tensor< Q > &R, const Tensor< Q > &T, const bool modified)
Definition convolution1d.h:208
double Tnormf
Definition convolution1d.h:170
Tensor< Q > R
Definition convolution1d.h:165
Tensor< Q > TVT
SVD approximations to R and T.
Definition convolution1d.h:166
Tensor< Q > RVT
Definition convolution1d.h:166
Definition convolution1d.h:990
static std::shared_ptr< GaussianConvolution1D< Q > > get(int k, double expnt, int m, bool periodic, double bloch_k=0.0, const KernelRange &range={})
Definition convolution1d.h:995
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< Q > > >::iterator iterator
Definition convolution1d.h:992
static ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< Q > > > map
Definition convolution1d.h:991
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< Q > > >::datumT datumT
Definition convolution1d.h:993
Definition convolution1d.h:688
returnT operator()(double x) const
Definition convolution1d.h:697
Tensor< Q > returnT
Definition convolution1d.h:689
Translation lx
Definition convolution1d.h:691
Level n
Definition convolution1d.h:690
Shmoo(Level n, Translation lx, const GenericConvolution1D< Q, opT > *q)
Definition convolution1d.h:694
const GenericConvolution1D< Q, opT > & q
Definition convolution1d.h:692
Definition kahan_accumulator.h:14
static const double x0
Definition tdse1d.cc:145
static const double s0
Definition tdse4.cc:83
Defines and implements most of Tensor.
Prototypes for a partial interface from Tensor to LAPACK.
bool is_small(const double &val, const double &eps)
Definition test6.cc:56
double norm(const T i1)
Definition test_cloud.cc:72
void e()
Definition test_sig.cc:75
constexpr std::size_t NDIM
Definition testgconv.cc:54
double h(const coord_1d &r)
Definition testgconv.cc:175
Implement the madness:Vector class, an extension of std::array that supports some mathematical operat...
const double a2
Definition vnucso.cc:86
const double a1
Definition vnucso.cc:85