32 #ifndef MADNESS_MRA_CONVOLUTION1D_H__INCLUDED
33 #define MADNESS_MRA_CONVOLUTION1D_H__INCLUDED
53 void aligned_add(
long n,
double* MADNESS_RESTRICT
a,
const double* MADNESS_RESTRICT
b);
54 void aligned_sub(
long n,
double* MADNESS_RESTRICT
a,
const double* MADNESS_RESTRICT
b);
59 static void copy_2d_patch(
T* MADNESS_RESTRICT out,
long ldout,
const T* MADNESS_RESTRICT in,
long ldin,
long n,
long m) {
60 for (
long i=0; i<n; ++i, out+=ldout, in+=ldin) {
61 for (
long j=0; j<
m; ++j) {
80 for (
long i=0; i<nm; ++i)
b[i] =
a[i];
87 for (
long i=0; i<n4; i+=4, a0+=m4) {
91 T* MADNESS_RESTRICT bi =
b+i;
92 for (
long j=0; j<
m; ++j, bi+=n) {
105 for (
long i=n4; i<n; ++i)
106 for (
long j=0; j<
m; ++j)
160 template <
typename Q>
190 for (
int i=0; i<
k; ++i)
191 for (
int j=0; j<
k; ++j)
232 for (
int i=0; i<n; ++i) {
233 for (
int j=0; j<n; ++j) {
237 for (
int i=n-1; i>1; --i) {
243 double rnorm = 1.0/
norm;
244 for (
int i=0; i<n; ++i) {
256 template <
typename Q>
315 if (!
issmall(n,
R*twon+lx))
return false;
347 R.scale(
pow(0.5,0.5*n));
399 if (t_off==0 and s_off==0)
T=
copy(Rm(
s0,
s0));
400 if (t_off==0 and s_off==1)
T=
copy(Rm(
s0,s1));
401 if (t_off==1 and s_off==0)
T=
copy(Rm(s1,
s0));
402 if (t_off==1 and s_off==1)
T=
copy(Rm(s1,s1));
542 template <
typename Q,
int NDIM>
544 std::array<std::shared_ptr<Convolution1D<Q> >,
NDIM>
ops;
557 std::fill(
ops.begin(),
ops.end(),
op);
564 std::shared_ptr<Convolution1D<Q> >
getop(
int dim)
const {
578 template <
typename Q>
594 for (
int mm=0; mm<
m; ++mm) ee *= x;
604 template <
typename Q,
typename opT>
651 Q f =
q.op(fac*x)*sqrt(fac);
653 for (
long p=0;
p<twok; ++
p)
v(
p) +=
f*phix[
p];
659 return adq1(lx, lx+1,
Shmoo(n, lx,
this), 1
e-12,
664 if (lx < 0) lx = 1 - lx;
667 if (lx <= 7)
return false;
670 if (n >= 0) lx = lx << n;
682 template <
typename Q>
700 int m,
bool periodic,
double arg = 0.0)
741 int twok = 2*this->
k;
745 if (lx<0) lx = -lx-1;
779 double fourn =
std::pow(4.0,
double(n));
781 double h = 1.0/sqrt(
beta);
782 long nbox = long(1.0/
h);
783 if (nbox < 1) nbox = 1;
795 double argmax =
std::abs(log(1
e-22/sch));
797 for (
long box=0; box<nbox; ++box) {
798 double xlo = box*
h + lx;
799 if (
beta*xlo*xlo > argmax)
break;
800 for (
long i=0; i<this->
npt; ++i) {
806 double xx = xlo +
h*this->
quad_x(i);
818 for (
long p=0;
p<twok; ++
p)
v(
p) += ee*phix[
p];
825 for (
long p=0;
p<twok; ++
p)
v(
p) = -
v(
p);
826 for (
long p=1;
p<twok;
p+=2)
v(
p) = -
v(
p);
843 return (
beta*ll*ll > 49.0);
848 template <
typename Q>
854 static std::shared_ptr< GaussianConvolution1D<Q> >
get(
int k,
double expnt,
int m,
bool periodic) {
864 if (it ==
map.end()) {
887 ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D<double> > >
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:257
Convolution1D(int k, int npt, int maxR, double arg=0.0)
Definition: convolution1d.h:277
SimpleCache< Tensor< Q >, 1 > rnlp_cache
Definition: convolution1d.h:270
Tensor< double > hgT2k
Definition: convolution1d.h:267
virtual Level natural_level() const
Returns the level for projection.
Definition: convolution1d.h:325
int maxR
Number of lattice translations for sum.
Definition: convolution1d.h:262
Tensor< double > hg
Definition: convolution1d.h:266
int k
Wavelet order.
Definition: convolution1d.h:260
SimpleCache< ConvolutionData1D< Q >, 1 > ns_cache
Definition: convolution1d.h:272
Tensor< double > hgT
Definition: convolution1d.h:266
Tensor< double > c
Definition: convolution1d.h:265
virtual Tensor< Q > rnlp(Level n, Translation lx) const =0
Compute the projection of the operator onto the double order polynomials.
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:359
SimpleCache< Tensor< Q >, 1 > rnlij_cache
Definition: convolution1d.h:271
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:336
int npt
Number of quadrature points (is this used?)
Definition: convolution1d.h:261
const Tensor< Q > & get_rnlp(Level n, Translation lx) const
Definition: convolution1d.h:498
const ConvolutionData1D< Q > * nonstandard(Level n, Translation lx) const
Returns a pointer to the cached make_nonstandard form of the operator.
Definition: convolution1d.h:426
virtual ~Convolution1D()
Definition: convolution1d.h:275
Tensor< double > quad_w
Definition: convolution1d.h:264
Q phase(double R) const
Definition: convolution1d.h:489
SimpleCache< ConvolutionData1D< Q >, 2 > mod_ns_cache
Definition: convolution1d.h:273
bool get_issmall(Level n, Translation lx) const
Returns true if the block of rnlp is expected to be small including periodicity.
Definition: convolution1d.h:308
Tensor< double > quad_x
Definition: convolution1d.h:263
virtual bool issmall(Level n, Translation lx) const =0
Returns true if the block of rnlp is expected to be small.
Q phase(double_complex R) const
Definition: convolution1d.h:493
double arg
Definition: convolution1d.h:268
Q opT
The apply function uses this to infer resultT=opT*inputT.
Definition: convolution1d.h:259
Array of 1D convolutions (one / dimension)
Definition: convolution1d.h:543
std::shared_ptr< Convolution1D< Q > > getop(int dim) const
Definition: convolution1d.h:564
void setop(int dim, const std::shared_ptr< Convolution1D< Q > > &op)
Definition: convolution1d.h:560
ConvolutionND(const ConvolutionND &other)
Definition: convolution1d.h:550
ConvolutionND()
Definition: convolution1d.h:548
std::array< std::shared_ptr< Convolution1D< Q > >, NDIM > ops
Definition: convolution1d.h:544
Q fac
Definition: convolution1d.h:545
ConvolutionND(std::shared_ptr< Convolution1D< Q > > op, Q fac=1.0)
Definition: convolution1d.h:555
Q getfac() const
Definition: convolution1d.h:572
void setfac(Q value)
Definition: convolution1d.h:568
1D convolution with (derivative) Gaussian; coeff and expnt given in simulation coordinates [0,...
Definition: convolution1d.h:683
const int m
Order of derivative (0, 1, or 2 only)
Definition: convolution1d.h:697
static int maxR(bool periodic, double expnt)
Definition: convolution1d.h:685
Tensor< Q > rnlp(Level n, Translation lx) const
Compute the projection of the operator onto the double order polynomials.
Definition: convolution1d.h:740
virtual Level natural_level() const
Returns the level for projection.
Definition: convolution1d.h:719
bool issmall(Level n, Translation lx) const
Returns true if the block is expected to be small.
Definition: convolution1d.h:833
GaussianConvolution1D(int k, Q coeff, double expnt, int m, bool periodic, double arg=0.0)
Definition: convolution1d.h:699
virtual ~GaussianConvolution1D()
Definition: convolution1d.h:717
const double expnt
Exponent.
Definition: convolution1d.h:695
const Level natlev
Level to evaluate.
Definition: convolution1d.h:696
const Q coeff
Coefficient.
Definition: convolution1d.h:694
Definition: convolution1d.h:579
Q coeff
Definition: convolution1d.h:581
int m
Definition: convolution1d.h:583
Level natural_level() const
Definition: convolution1d.h:597
Level natlev
Definition: convolution1d.h:584
GaussianGenericFunctor(Q coeff, double exponent, int m=0)
Definition: convolution1d.h:588
Q operator()(double x) const
Definition: convolution1d.h:592
double exponent
Definition: convolution1d.h:582
Generic 1D convolution using brute force (i.e., slow) adaptive quadrature for rnlp.
Definition: convolution1d.h:605
opT op
Definition: convolution1d.h:607
bool issmall(Level n, Translation lx) const
Returns true if the block of rnlp is expected to be small.
Definition: convolution1d.h:663
long maxl
At natural level is l beyond which operator is zero.
Definition: convolution1d.h:608
Tensor< Q > rnlp(Level n, Translation lx) const
Compute the projection of the operator onto the double order polynomials.
Definition: convolution1d.h:658
virtual Level natural_level() const
Returns the level for projection.
Definition: convolution1d.h:635
GenericConvolution1D()
Definition: convolution1d.h:611
GenericConvolution1D(int k, const opT &op, int maxR, double arg=0.0)
Definition: convolution1d.h:613
iterator for hash
Definition: worldhashmap.h:188
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:66
Level level() const
Definition: key.h:159
const Vector< Translation, NDIM > & translation() const
Definition: key.h:164
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
T * ptr()
Returns a pointer to the internal data.
Definition: tensor.h:1824
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition: tensor.h:1726
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
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
const double m
Definition: gfit.cc:199
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 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:190
#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
const double pi
Mathematical constant .
Definition: constants.h:48
double norm(const T &t)
Definition: adquad.h:42
File holds all helper structures necessary for the CC_Operator and CC2 class.
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:69
void legendre_scaling_functions(double x, long k, double *p)
Evaluate the first k Legendre scaling functions.
Definition: legendre.cc:85
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:2002
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:54
int Level
Definition: key.h:55
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:59
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:2416
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
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
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition: array_addons.h:78
static long abs(long a)
Definition: tensor.h:218
static const double b
Definition: nonlinschro.cc:119
static const double a
Definition: nonlinschro.cc:118
double Q(double a)
Definition: relops.cc:20
static const long k
Definition: rk.cc:44
!!! Note that if Rnormf is zero then ALL of the tensors are empty
Definition: convolution1d.h:161
Tensor< Q > T
if NS: R=ns, T=T part of ns; if modified NS: T=\uparrow r^(n-1)
Definition: convolution1d.h:164
double Rnorm
Definition: convolution1d.h:169
Tensor< typename Tensor< Q >::scalar_type > Rs
Definition: convolution1d.h:166
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:228
double N_up
Definition: convolution1d.h:172
double NSnormf
Definition: convolution1d.h:169
double Rnormf
Definition: convolution1d.h:169
Tensor< Q > TU
Definition: convolution1d.h:165
ConvolutionData1D(const Tensor< Q > &R, const Tensor< Q > &T)
Definition: convolution1d.h:179
double N_F
the norms according to Beylkin 2008, Eq. (21) ff
Definition: convolution1d.h:172
double N_diff
Definition: convolution1d.h:172
Tensor< Q > RU
Definition: convolution1d.h:165
double Tnorm
Definition: convolution1d.h:169
Tensor< typename Tensor< Q >::scalar_type > Ts
hold relative errors, NOT the singular values..
Definition: convolution1d.h:166
ConvolutionData1D(const Tensor< Q > &R, const Tensor< Q > &T, const bool modified)
Definition: convolution1d.h:207
double Tnormf
Definition: convolution1d.h:169
Tensor< Q > R
Definition: convolution1d.h:164
Tensor< Q > TVT
SVD approximations to R and T.
Definition: convolution1d.h:165
Tensor< Q > RVT
Definition: convolution1d.h:165
Definition: convolution1d.h:849
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< Q > > >::datumT datumT
Definition: convolution1d.h:852
static ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< Q > > > map
Definition: convolution1d.h:850
ConcurrentHashMap< hashT, std::shared_ptr< GaussianConvolution1D< Q > > >::iterator iterator
Definition: convolution1d.h:851
static std::shared_ptr< GaussianConvolution1D< Q > > get(int k, double expnt, int m, bool periodic)
Definition: convolution1d.h:854
Definition: convolution1d.h:637
returnT operator()(double x) const
Definition: convolution1d.h:646
Tensor< Q > returnT
Definition: convolution1d.h:638
Translation lx
Definition: convolution1d.h:640
Level n
Definition: convolution1d.h:639
Shmoo(Level n, Translation lx, const GenericConvolution1D< Q, opT > *q)
Definition: convolution1d.h:643
const GenericConvolution1D< Q, opT > & q
Definition: convolution1d.h:641
static const double s0
Definition: tdse4.cc:83
Defines and implements most of Tensor.
Prototypes for a partial interface from Tensor to LAPACK.
void e()
Definition: test_sig.cc:75
double h(const coord_1d &r)
Definition: testgconv.cc:68
static const std::size_t NDIM
Definition: testpdiff.cc:42
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