MADNESS 0.10.1
gfit.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30
31
32 $Id: key.h 2907 2012-06-14 10:15:05Z 3ru6ruWu $
33 */
34
35#ifndef MADNESS_MRA_GFIT_H__INCLUDED
36#define MADNESS_MRA_GFIT_H__INCLUDED
37
38/// \file gfit.h
39/// \brief fit isotropic functions to a set of Gaussians with controlled precision
40
41//#include <iostream>
42
43#include <cmath>
44#include "../constants.h"
46#include "../tensor/slice.h"
47#include "../tensor/tensor.h"
50#include "../world/print.h"
52#include <algorithm>
54
55
56namespace madness {
57
58template<typename T, std::size_t NDIM>
59class GFit {
60
61public:
62
63 /// default ctor does nothing
64 GFit() = default;
65
67 double mu = info.mu;
68 double lo = info.lo;
69 double hi = info.hi;
70 MADNESS_CHECK_THROW(hi>0,"hi must be positive in gfit: U need to set it manually in operator.h");
71 double eps = info.thresh;
72 bool debug=info.debug;
73 OpType type = info.type;
74
75
76 if (type==OT_G12) {*this=CoulombFit(lo,hi,eps,debug);
77 } else if (type==OT_SLATER) {*this=SlaterFit(mu,lo,hi,eps,debug);
78 } else if (type==OT_GAUSS) {*this=GaussFit(mu,lo,hi,eps,debug);
79 } else if (type==OT_F12) {*this=F12Fit(mu,lo,hi,eps,debug);
80 } else if (type==OT_FG12) {*this=FGFit(mu,lo,hi,eps,debug);
81 } else if (type==OT_F212) {*this=F12sqFit(mu,lo,hi,eps,debug);
82 } else if (type==OT_F2G12) {*this=F2GFit(mu,lo,hi,eps,debug);
83 } else if (type==OT_BSH) {*this=BSHFit(mu,lo,hi,eps,debug);
84 } else if (type==OT_INVRSQ) {*this=InverseRSqFit(lo,hi,eps,debug);
85 } else {
86 print("Operator type not implemented: ",type);
87 MADNESS_EXCEPTION("Operator type not implemented: ",1);
88 }
89
90 }
91
92 /// copy constructor
93 GFit(const GFit& other) = default;
94
95 /// assignment operator
96 GFit& operator=(const GFit& other) {
97 coeffs_ = other.coeffs_;
98 exponents_ = other.exponents_;
99 return *this;
100 }
101
102 /// return a fit for the Coulomb function
103
104 /// f(r) = 1/r
105 static GFit CoulombFit(double lo, double hi, double eps, bool prnt=false) {
106 GFit fit=BSHFit(0.0,lo,hi,eps/(4.0*constants::pi),prnt);
107 fit.coeffs_.scale(4.0*constants::pi); // BSHFit scales by 1/(4 pi), undo here
108 return fit;
109 }
110
111 /// return a fit for the inverse-square function 1/r^2
112
113 /// Built from the Beylkin-Monzon integral representation
114 /// 1/r^2 = ∫_0^∞ exp(-t r^2) dt
115 /// After the substitution t = exp(2s), this is trapezoidally
116 /// discretized to give 1/r^2 ≈ Σ_k c_k exp(-α_k r^2) with
117 /// c_k = 2 h exp(2 s_k), α_k = exp(2 s_k).
118 ///
119 /// Implementation is a thin wrapper around bsh_fit_ndim(4, 0, ...),
120 /// which fits the 4-D Poisson Green's function (proportional to 1/r^2
121 /// with a factor 0.5/π^2). The coefficients are rescaled by 4π^2 so
122 /// that the returned fit is the pointwise approximation of 1/r^2.
123 ///
124 /// @param[in] lo the smallest length scale that needs to be precisely represented
125 /// @param[in] hi the largest length scale that needs to be precisely represented
126 /// @param[in] eps the precision threshold
127 /// @param[in] prnt print level
128 static GFit InverseRSqFit(double lo, double hi, double eps, bool prnt=false) {
129 GFit fit;
130 // Direct Beylkin-Monzon discretization of
131 // 1/r^2 = 2 ∫_{-∞}^{+∞} exp(2s) exp(-exp(2s) r^2) ds
132 // with trapezoidal rule in s.
133 double TT;
134 if (eps >= 1e-4) TT = 10.0;
135 else if (eps >= 1e-6) TT = 14.0;
136 else if (eps >= 1e-8) TT = 18.0;
137 else if (eps >= 1e-10) TT = 22.0;
138 else if (eps >= 1e-12) TT = 26.0;
139 else TT = 30.0;
140 double slo = std::log(eps/hi) - 1.0;
141 double shi = 0.5 * std::log(TT/(lo*lo));
142 double h = 1.0/(0.2 - 0.5*std::log10(eps));
143 h = std::floor(64.0*h)/64.0;
144 shi = std::ceil(shi/h)*h;
145 slo = std::floor(slo/h)*h;
146 long npt = long((shi - slo)/h + 0.5);
147
148 std::vector<double> c_vec, a_vec;
149 for (int i=0; i<npt; ++i) {
150 double s = slo + h*(npt - i);
151 double alpha = std::exp(2.0*s);
152 double coeff = 2.0*h*alpha;
153 c_vec.push_back(coeff);
154 a_vec.push_back(alpha);
155 }
156 fit.coeffs_ = Tensor<double>(long(c_vec.size()));
157 fit.exponents_ = Tensor<double>(long(a_vec.size()));
158 for (size_t i=0; i<c_vec.size(); ++i) {
159 fit.coeffs_[i] = c_vec[i];
160 fit.exponents_[i] = a_vec[i];
161 }
162 if (prnt) {
163 print("inverse-square fit");
164 auto exact = [](const double r) -> double { return 1.0/(r*r); };
165 fit.print_accuracy(exact, lo, hi);
166 }
167 return fit;
168 }
169
170 /// return a fit for the bound-state Helmholtz function
171
172 /// the BSH function is defined by
173 /// f(r) = 1/ (4 pi) exp(-\mu r)/r
174 /// @param[in] mu the exponent of the BSH
175 /// @param[in] lo the smallest length scale that needs to be precisely represented
176 /// @param[in] hi the largest length scale that needs to be precisely represented
177 /// @param[in] eps the precision threshold
178 /// @parma[in] prnt print level
179 static GFit BSHFit(double mu, double lo, double hi, double eps, bool prnt=false) {
180 GFit fit;
181 bool fix_interval=false;
182 if (NDIM==3) bsh_fit(mu,lo,hi,eps,fit.coeffs_,fit.exponents_,prnt,fix_interval);
183 else bsh_fit_ndim(NDIM,mu,lo,hi,eps,fit.coeffs_,fit.exponents_,prnt);
184
185 if (prnt) {
186 print("bsh fit");
187 auto exact = [&mu](const double r) -> double { return 1.0/(4.0 * constants::pi) * exp(-mu * r)/r; };
188 fit.print_accuracy(exact, lo, hi);
189 }
190 return fit;
191 }
192
193 /// return a fit for the Slater function
194
195 /// the Slater function is defined by
196 /// f(r) = exp(-\gamma r)
197 /// @param[in] gamma the exponent of the Slater function
198 /// @param[in] lo the smallest length scale that needs to be precisely represented
199 /// @param[in] hi the largest length scale that needs to be precisely represented
200 /// @param[in] eps the precision threshold
201 /// @parma[in] prnt print level
202 static GFit SlaterFit(double gamma, double lo, double hi, double eps, bool prnt=false) {
203 GFit fit;
204 slater_fit(gamma,lo,hi,eps,fit.coeffs_,fit.exponents_,false);
205 if (prnt) {
206 print("Slater fit");
207 auto exact = [&gamma](const double r) -> double { return exp(-gamma * r); };
208 fit.print_accuracy(exact, lo, hi);
209 }
210 return fit;
211 }
212
213 /// return a (trivial) fit for a single Gauss function
214
215 /// the Gauss function is defined by
216 /// f(r) = exp(-\gamma r^2)
217 /// @param[in] gamma the exponent of the Gauss function
218 /// @param[in] lo the smallest length scale that needs to be precisely represented
219 /// @param[in] hi the largest length scale that needs to be precisely represented
220 /// @param[in] eps the precision threshold
221 /// @parma[in] prnt print level
222 static GFit GaussFit(double gamma, double lo, double hi, double eps, bool prnt=false) {
223 GFit fit;
224 fit.coeffs_=Tensor<T>(1);
225 fit.exponents_=Tensor<double>(1);
226 fit.coeffs_=1.0;
227 fit.exponents_=gamma;
228 if (prnt) {
229 print("Gauss fit");
230 auto exact = [&gamma](const double r) -> double { return exp(-gamma * r*r); };
231 fit.print_accuracy(exact, lo, hi);
232 }
233 return fit;
234 }
235
236 /// return a fit for the F12 correlation factor
237
238 /// the Slater function is defined by
239 /// f(r) = 1/(2 gamma) * (1 - exp(-\gamma r))
240 /// @param[in] gamma the exponent of the Slater function
241 /// @param[in] lo the smallest length scale that needs to be precisely represented
242 /// @param[in] hi the largest length scale that needs to be precisely represented
243 /// @param[in] eps the precision threshold
244 /// @parma[in] prnt print level
245 static GFit F12Fit(double gamma, double lo, double hi, double eps, bool prnt=false) {
246 GFit fit;
247 f12_fit(gamma,lo*0.1,hi,eps*0.01,fit.coeffs_,fit.exponents_,false);
248 fit.coeffs_*=(0.5/gamma);
249 if (prnt) {
250 print("f12 fit");
251 auto exact=[&gamma](const double r) -> double {return 0.5/gamma*(1.0-exp(-gamma*r));};
252 fit.print_accuracy(exact,lo,hi);
253 }
254 return fit;
255 }
256
257 /// return a fit for the F12^2 correlation factor
258
259 /// the Slater function square is defined by
260 /// f(r) = [ 1/(2 gamma) * (1 - exp(-\gamma r)) ] ^2
261 /// @param[in] gamma the exponent of the Slater function
262 /// @param[in] lo the smallest length scale that needs to be precisely represented
263 /// @param[in] hi the largest length scale that needs to be precisely represented
264 /// @param[in] eps the precision threshold
265 /// @parma[in] prnt print level
266 static GFit F12sqFit(double gamma, double lo, double hi, double eps, bool prnt=false) {
267 GFit fit;
268 f12sq_fit(gamma,lo*0.1,hi,eps*0.01,fit.coeffs_,fit.exponents_,false);
269 fit.coeffs_*=(0.25/(gamma*gamma));
270 if (prnt) {
271 print("f12sq fit");
272 auto exact=[&gamma](const double r) -> double {return std::pow(0.5/gamma*(1.0-exp(-gamma*r)),2.0);};
273 fit.print_accuracy(exact,lo,hi);
274 }
275 return fit;
276 }
277
278
279 /// return a fit for the FG function
280
281 /// fg = 1/(2 mu) * (1 - exp(-gamma r12)) / r12
282 /// = 1/(2 mu) *( 1/r12 - exp(-gamma r12)/r12)
283 /// = 1/(2 mu) * (coulomb - bsh)
284 /// @param[in] gamma the exponent of the Slater function
285 /// @param[in] lo the smallest length scale that needs to be precisely represented
286 /// @param[in] hi the largest length scale that needs to be precisely represented
287 /// @param[in] eps the precision threshold
288 /// @parma[in] prnt print level
289 static GFit FGFit(double gamma, double lo, double hi, double eps, bool prnt=false) {
290 GFit bshfit,coulombfit;
291 eps*=0.1;
292 lo*=0.1;
293// bool restrict_interval=false;
294 bool fix_interval=true;
295 bsh_fit(gamma,lo,hi,eps,bshfit.coeffs_,bshfit.exponents_,false,fix_interval);
296 bsh_fit(0.0,lo,hi,eps,coulombfit.coeffs_,coulombfit.exponents_,false,fix_interval);
297 // check the exponents are identical
298 auto diffexponents=(coulombfit.exponents() - bshfit.exponents());
299 MADNESS_CHECK(diffexponents.normf()/coulombfit.exponents().size()<1.e-12);
300 auto diffcoefficients=(coulombfit.coeffs() - bshfit.coeffs());
301 GFit fgfit;
302 fgfit.exponents_=bshfit.exponents_;
303 fgfit.coeffs_=4.0*constants::pi*0.5/gamma*diffcoefficients;
305
306 if (prnt) {
307 print("fg fit");
308 auto exact=[&gamma](const double r) -> double {return 0.5/gamma*(1.0-exp(-gamma*r))/r;};
309 fgfit.print_accuracy(exact,lo,hi);
310 }
311 return fgfit;
312 }
313
314 /// return a fit for the F2G function
315
316 /// f2g = (1/(2 mu) * (1 - exp(-gamma r12)))^2 / r12
317 /// = 1/(4 mu^2) * [ 1/r12 - 2 exp(-gamma r12)/r12) + exp(-2 gamma r12)/r12 ]
318 /// @param[in] gamma the exponent of the Slater function
319 /// @param[in] lo the smallest length scale that needs to be precisely represented
320 /// @param[in] hi the largest length scale that needs to be precisely represented
321 /// @param[in] eps the precision threshold
322 /// @parma[in] prnt print level
323 static GFit F2GFit(double gamma, double lo, double hi, double eps, bool prnt=false) {
324 GFit bshfit,coulombfit,bsh2fit;
325 eps*=0.1;
326 lo*=0.1;
327// bool restrict_interval=false;
328 bool fix_interval=true;
329 bsh_fit(gamma,lo,hi,eps,bshfit.coeffs_,bshfit.exponents_,false,fix_interval);
330 bsh_fit(2.0*gamma,lo,hi,eps,bsh2fit.coeffs_,bsh2fit.exponents_,false,fix_interval);
331 bsh_fit(0.0,lo,hi,eps,coulombfit.coeffs_,coulombfit.exponents_,false,fix_interval);
332
333 // check the exponents are identical
334 auto diffexponents=(coulombfit.exponents() - bshfit.exponents());
335 MADNESS_CHECK(diffexponents.normf()/coulombfit.exponents().size()<1.e-12);
336 auto diffexponents1=(coulombfit.exponents() - bsh2fit.exponents());
337 MADNESS_CHECK(diffexponents1.normf()/coulombfit.exponents().size()<1.e-12);
338
339 auto coefficients=(coulombfit.coeffs() - 2.0* bshfit.coeffs() + bsh2fit.coeffs());
340 GFit f2gfit;
341 f2gfit.exponents_=bshfit.exponents_;
342 // additional factor 4 pi due to implementation of bsh_fit
343 double fourpi=4.0*constants::pi;
344 double fourmu2=4.0*gamma*gamma;
345 f2gfit.coeffs_=fourpi/fourmu2*coefficients;
347
348 if (prnt) {
349 print("fg fit");
350 auto exact=[&gamma](const double r) -> double {
351 return 0.25/(gamma*gamma)*(1.0-2.0*exp(-gamma*r)+exp(-2.0*gamma*r))/r;
352 };
353 f2gfit.print_accuracy(exact,lo,hi);
354 }
355 return f2gfit;
356 }
357
358
359 /// return a fit for a general isotropic function
360
361 /// note that the error is controlled over a uniform grid, the boundaries
362 /// will be poorly represented in general. Following Beylkin 2005
363 static GFit GeneralFit() {
364 MADNESS_EXCEPTION("General GFit still to be implemented",1);
365 return GFit();
366 }
367
368 /// return the coefficients of the fit
369 Tensor<T> coeffs() const {return coeffs_;}
370
371 /// return the exponents of the fit
373
374 /// Fold the most diffuse Gaussians of a fit into their neighbours while the fit stays accurate
375 /// to eps on [lo, hi]. Works from the tail inwards and stops at the first term that cannot be
376 /// merged; terms before `first_prunable` are never merged into (so `first_prunable - 1` and
377 /// everything before it keep their coefficients).
378 void static prune_small_coefficients(const double eps, const double lo, const double hi,
379 Tensor<double>& coeff, Tensor<double>& expnt,
380 const long first_prunable = 1) {
381 double mid = lo + (hi-lo)*0.5;
382 long npt=coeff.size();
383 long i;
384 for (i=npt-1; i>=std::max(first_prunable, 1L); --i) {
385 double cnew = coeff[i]*exp(-(expnt[i]-expnt[i-1])*mid*mid);
386 double errlo = coeff[i]*exp(-expnt[i]*lo*lo) -
387 cnew*exp(-expnt[i-1]*lo*lo);
388 double errhi = coeff[i]*exp(-expnt[i]*hi*hi) -
389 cnew*exp(-expnt[i-1]*hi*hi);
390 if (std::max(std::abs(errlo),std::abs(errhi)) > 0.03*eps) break;
391 npt--;
392 coeff[i-1] = coeff[i-1] + cnew;
393 }
394 coeff = coeff(Slice(0,npt-1));
395 expnt = expnt(Slice(0,npt-1));
396 }
397
398 /// Truncate the fit of a kernel that is lattice-summed along some axes
399
400 /// Along an axis with an infinite lattice sum, a Gaussian with exponent below
401 /// tcut = 0.25/L^2 (L the largest such cell width) has a lattice sum that is flat to
402 /// exp(-4 pi^2) over the cell: a gauge constant. If every axis is summed, those terms
403 /// are dropped (all but the first, as before). If some axes are not summed, the same
404 /// terms are not flat along them and carry real potential there -- so they
405 /// are kept as far as the finite axes need them: the tail is folded into its neighbours
406 /// while the fit stays accurate to eps on [lo, hi_fin], where hi_fin is the largest
407 /// distance the finite axes can reach. The first term below tcut is never merged into a
408 /// term above it, whose lattice sum is not flat.
409 /// @param[in,out] c coefficients of the fit; truncated (and possibly rescaled) on return
410 /// @param[in,out] e exponents of the fit, in decreasing order
411 /// @param[in] lattice_ranges lattice range of each axis
412 /// @param[in] cell_width width of each axis of the cell
413 /// @param[in] lo smallest distance the fit must represent accurately
414 /// @param[in] hi_fin largest distance the finite (non-infinite) axes must represent accurately
415 /// @param[in] eps accuracy of the fit on [lo, hi_fin]
417 const std::array<LatticeRange, NDIM>& lattice_ranges,
419 double lo, double hi_fin, double eps) {
420 const bool infinite_any = std::any_of(lattice_ranges.begin(), lattice_ranges.end(), [](const auto& b) { return b.infinite(); });
421 const bool infinite_all = std::all_of(lattice_ranges.begin(), lattice_ranges.end(), [](const auto& b) { return b.infinite(); });
422 if (!infinite_any) return; // no lattice sum is a constant: nothing can be dropped
423
424 // The widest infinitely summed axis determines how "diffuse" a Gaussian sum needs to be for
425 // all infinite lattice sums to be constant.
426 double max_infinite_width = 0;
427 for (std::size_t d = 0; d != NDIM; ++d)
428 if (lattice_ranges[d].infinite()) max_infinite_width = std::max(max_infinite_width, cell_width(long(d)));
429 const double tcut = 0.25 / (max_infinite_width * max_infinite_width);
430
431 // the first term whose lattice sums are flat (exponents decrease with the index)
432 long icut = -1;
433 for (long i = 0; i < e.dim(0); ++i) {
434 if (e(i) < tcut) { icut = i; break; }
435 }
436 if (icut < 0) return; // no diffuse terms
437
438 if (infinite_all) { // every axis is summed: the diffuse tail is a constant, keep its first term only
439 c = c(Slice(0, icut));
440 e = e(Slice(0, icut));
441 return;
442 }
443 // mixed: fold the tail into its neighbours as far as the finite axes allow. The first
444 // prunable term is icut + 1, so icut may absorb its neighbours but the term before it,
445 // whose lattice sum is not flat, is never touched.
446 prune_small_coefficients(eps, lo, hi_fin, c, e, /* first_prunable = */ icut + 1);
447 }
448
449private:
450
451 /// ctor taking an isotropic function
452
453 /// the function will be represented with a uniform error on a uniform grid
454 /// @param[in] f a 1d-function that implements T operator()
455 template<typename funcT>
456 GFit(const funcT& f) {
457
458 }
459
460 /// print coefficients and exponents, and values and errors
461
462 /// @param[in] op the exact function, e.g. 1/r, exp(-mu r), etc
463 /// @param[in] lo lower bound for the range r
464 /// @param[in] hi higher bound for the range r
465 template<typename opT>
466 void print_accuracy(opT op, const double lo, const double hi) const {
467
468 std::cout << "weights and roots" << std::endl;
469 for (int i=0; i<coeffs_.size(); ++i)
470 std::cout << i << " " << coeffs_[i] << " " << exponents_[i] << std::endl;
471
472 long npt = 300;
473 std::cout << " x value abserr relerr" << std::endl;
474 std::cout << " ------------ ------- -------- -------- " << std::endl;
475 double step = exp(log(hi/lo)/(npt+1));
476 for (int i=0; i<=npt; ++i) {
477 double r = lo*(pow(step,i+0.5));
478// double exact = exp(-mu*r)/r/4.0/constants::pi;
479 double exact = op(r);
480 double test = 0.0;
481 for (int j=0; j<coeffs_.dim(0); ++j)
482 test += coeffs_[j]*exp(-r*r*exponents_[j]);
483 double err = 0.0;
484 if (exact) err = (exact-test)/exact;
485 printf(" %.6e %8.1e %8.1e %8.1e\n",r, exact, exact-test, err);
486 }
487 }
488
489 /// the coefficients of the expansion f(x) = \sum_m coeffs[m] exp(-exponents[m] * x^2)
491
492 /// the exponents of the expansion f(x) = \sum_m coeffs[m] exp(-exponents[m] * x^2)
494
495 /// fit the function exp(-mu r)/r
496
497 /// formulas taken from
498 /// G. Beylkin and L. Monzon, On approximation of functions by exponential sums,
499 /// Appl Comput Harmon A, vol. 19, no. 1, pp. 17-48, Jul. 2005.
500 /// and
501 /// R. J. Harrison, G. I. Fann, T. Yanai, and G. Beylkin,
502 /// Multiresolution Quantum Chemistry in Multiwavelet Bases,
503 /// Lecture Notes in Computer Science, vol. 2660, p. 103, 2003.
504 static void bsh_fit(double mu, double lo, double hi, double eps,
505 Tensor<double>& pcoeff, Tensor<double>& pexpnt, bool prnt, bool fix_interval) {
506
507 if (mu < 0.0) throw "cannot handle negative mu in bsh_fit";
508// bool restrict_interval=(mu>0) and use_mu_for_restricting_interval;
509
510
511 if ((mu > 0) and (not fix_interval)) {
512// if (restrict_interval) {
513 // Restrict hi according to the exponential decay
514 double r = -log(4*constants::pi*0.01*eps);
515 r = -log(r * 4*constants::pi*0.01*eps);
516 if (hi > r) hi = r;
517 }
518
519 double TT;
520 double slo, shi;
521
522 if (eps >= 1e-2) TT = 5;
523 else if (eps >= 1e-4) TT = 10;
524 else if (eps >= 1e-6) TT = 14;
525 else if (eps >= 1e-8) TT = 18;
526 else if (eps >= 1e-10) TT = 22;
527 else if (eps >= 1e-12) TT = 26;
528 else TT = 30;
529
530 if ((mu > 0) and (not fix_interval)) {
531// if (restrict_interval) {
532 slo = -0.5*log(4.0*TT/(mu*mu));
533 }
534 else {
535 slo = log(eps/hi) - 1.0;
536 }
537 shi = 0.5*log(TT/(lo*lo));
538 if (shi <= slo) throw "bsh_fit: logic error in slo,shi";
539
540 // Resolution required for quadrature over s
541 double h = 1.0/(0.2-.50*log10(eps)); // was 0.5 was 0.47
542
543 // Truncate the number of binary digits in h's mantissa
544 // so that rounding does not occur when performing
545 // manipulations to determine the quadrature points and
546 // to limit the number of distinct values in case of
547 // multiple precisions being used at the same time.
548 h = floor(64.0*h)/64.0;
549
550
551 // Round shi/lo up/down to an integral multiple of quadrature points
552 shi = ceil(shi/h)*h;
553 slo = floor(slo/h)*h;
554
555 long npt = long((shi-slo)/h+0.5);
556
557 //if (prnt)
558 //std::cout << "mu " << mu << " slo " << slo << " shi " << shi << " npt " << npt << " h " << h << " " << eps << std::endl;
559
560 Tensor<double> coeff(npt), expnt(npt);
561
562 for (int i=0; i<npt; ++i) {
563 double s = slo + h*(npt-i); // i+1
564 coeff[i] = h*2.0/sqrt(constants::pi)*exp(-mu*mu*exp(-2.0*s)/4.0)*exp(s);
565 coeff[i] = coeff[i]/(4.0*constants::pi);
566 expnt[i] = exp(2.0*s);
567 }
568
569#if ONE_TERM
570 npt=1;
571 double s=1.0;
572 coeff[0]=1.0;
573 expnt[0] = exp(2.0*s);
574 coeff=coeff(Slice(0,0));
575 expnt=expnt(Slice(0,0));
576 print("only one term in gfit",s,coeff[0],expnt[0]);
577
578
579#endif
580
581 // Prune large exponents from the fit ... never necessary due to construction
582
583 // Prune small exponents from Coulomb fit. Evaluate a gaussian at
584 // the range midpoint, and replace it there with the next most
585 // diffuse gaussian. Then examine the resulting error at the two
586 // end points ... if this error is less than the desired
587 // precision, can discard the diffuse gaussian.
588
589 if ((mu == 0.0) and (not fix_interval)) {
590// if (restrict_interval) {
592 }
593
594 // Modify the coeffs of the largest exponents to satisfy the moment conditions
595 //
596 // SETTING NMOM>1 TURNS OUT TO BE A BAD IDEA (AS CURRENTLY IMPLEMENTED)
597 // [It is accurate and efficient for a one-shot application but it seems to
598 // introduce fine-scale noise that amplifies during iterative solution of
599 // the SCF and DFT equations ... the symptom is negative coeffs in the fit]
600 //
601 // SET NMOM=0 or 1 (1 recommended) unless you are doing a one-shot application
602 //
603 // Determine the effective range of the four largest exponents and compute
604 // moments of the exact and remainder of the fit. Then adjust the coeffs
605 // to reproduce the exact moments in that volume.
606 //
607 // If nmom!=4 we assume that we will eliminate n=-1 which is stored first
608 // in the moment list
609 //
610 // <r^i|gj> cj = <r^i|exact-remainder>
611 const long nmom = 0;
612 if (nmom > 0) {
613 Tensor<double> q(4), qg(4);
614 double range = sqrt(-log(1e-6)/expnt[nmom-1]);
615 if (prnt) print("exponent(nmom-1)",expnt[nmom-1],"has range", range);
616
617 bsh_spherical_moments(mu, range, q);
618 Tensor<double> M(nmom,nmom);
619 for (int i=nmom; i<npt; ++i) {
620 Tensor<double> qt(4);
621 gaussian_spherical_moments(expnt[i], range, qt);
622 qg += qt*coeff[i];
623 }
624 if (nmom != 4) {
625 q = q(Slice(1,nmom));
626 qg = qg(Slice(1,nmom));
627 }
628 if (prnt) {
629 print("moments", q);
630 print("moments", qg);
631 }
632 q = q - qg;
633 for (int j=0; j<nmom; ++j) {
634 Tensor<double> qt(4);
635 gaussian_spherical_moments(expnt[j], range, qt);
636 if (nmom != 4) qt = qt(Slice(1,nmom));
637 for (int i=0; i<nmom; ++i) {
638 M(i,j) = qt[i];
639 }
640 }
641 Tensor<double> ncoeff;
642 gesv(M, q, ncoeff);
643 if (prnt) {
644 print("M\n",M);
645 print("old coeffs", coeff(Slice(0,nmom-1)));
646 print("new coeffs", ncoeff);
647 }
648
649 coeff(Slice(0,nmom-1)) = ncoeff;
650 }
651
652 pcoeff = coeff;
653 pexpnt = expnt;
654 }
655
656 /// fit a Slater function using a sum of Gaussians
657
658 /// formula inspired by the BSH fit, with the roles of r and mu exchanged
659 /// see also Eq. (A3) in
660 /// S. Ten-no, Initiation of explicitly correlated Slater-type geminal theory,
661 /// Chem. Phys. Lett., vol. 398, no. 1, pp. 56-61, 2004.
662 static void slater_fit(double gamma, double lo, double hi, double eps,
663 Tensor<double>& pcoeff, Tensor<double>& pexpnt, bool prnt) {
664
665 MADNESS_CHECK(gamma >0.0);
666 // empirical number TT for the upper integration limit
667 double TT;
668 if (eps >= 1e-2) TT = 5;
669 else if (eps >= 1e-4) TT = 10;
670 else if (eps >= 1e-6) TT = 14;
671 else if (eps >= 1e-8) TT = 18;
672 else if (eps >= 1e-10) TT = 22;
673 else if (eps >= 1e-12) TT = 26;
674 else TT = 30;
675
676 // integration limits for quadrature over s: slo and shi
677 // slo and shi must not depend on gamma!!!
678 double slo=0.5 * log(eps) - 1.0;
679 double shi=log(TT/(lo*lo))*0.5;
680
681 // Resolution required for quadrature over s
682 double h = 1.0/(0.2-.5*log10(eps)); // was 0.5 was 0.47
683
684 // Truncate the number of binary digits in h's mantissa
685 // so that rounding does not occur when performing
686 // manipulations to determine the quadrature points and
687 // to limit the number of distinct values in case of
688 // multiple precisions being used at the same time.
689 h = floor(64.0*h)/64.0;
690
691 // Round shi/lo up/down to an integral multiple of quadrature points
692 shi = ceil(shi/h)*h;
693 slo = floor(slo/h)*h;
694
695 long npt = long((shi-slo)/h+0.5);
696
697 Tensor<double> coeff(npt), expnt(npt);
698
699 for (int i=0; i<npt; ++i) {
700 const double s = slo + h*(npt-i); // i+1
701 coeff[i] = h*exp(-gamma*gamma*exp(2.0*s) + s);
702 coeff[i]*=2.0*gamma/sqrt(constants::pi);
703 expnt[i] = 0.25*exp(-2.0*s);
704 }
705
706 if (prnt) {
707 std::cout << "weights and roots for a Slater function with gamma=" << gamma << std::endl;
708 for (int i=0; i<npt; ++i)
709 std::cout << i << " " << coeff[i] << " " << expnt[i] << std::endl;
710
711 long npt = 300;
712 //double hi = 1.0;
713 //if (mu) hi = min(1.0,30.0/mu);
714 std::cout << " x value abserr relerr" << std::endl;
715 std::cout << " ------------ ------- -------- -------- " << std::endl;
716 double step = exp(log(hi/lo)/(npt+1));
717 for (int i=0; i<=npt; ++i) {
718 double r = lo*(pow(step,i+0.5));
719 double exact = exp(-gamma*r);
720 double test = 0.0;
721 for (int j=0; j<coeff.dim(0); ++j)
722 test += coeff[j]*exp(-r*r*expnt[j]);
723 double err = 0.0;
724 if (exact) err = (exact-test)/exact;
725 printf(" %.6e %8.1e %8.1e %8.1e\n",r, exact, exact-test, err);
726 }
727 }
728 pcoeff = coeff;
729 pexpnt = expnt;
730 }
731
732
733 /// fit a correlation factor (1- exp(-mu r))
734
735 /// use the Slater fit with an additional term: 1*exp(-0 r^2)
736 static void f12_fit(double gamma, double lo, double hi, double eps,
737 Tensor<double>& pcoeff, Tensor<double>& pexpnt, bool prnt) {
738 Tensor<double> coeff,expnt;
739 slater_fit(gamma, lo, hi, eps, coeff, expnt, prnt);
740
741 pcoeff=Tensor<double>(coeff.size()+1);
742 pcoeff(Slice(1,-1,1))=-coeff(_);
743 pexpnt=Tensor<double>(expnt.size()+1);
744 pexpnt(Slice(1,-1,1))=expnt(_);
745
746 pcoeff(0l)=1.0;
747 pexpnt(0l)=1.e-10;
748 }
749
750
751 /// fit a correlation factor f12^2 = (1- exp(-mu r))^2 = 1 - 2 exp(-mu r) + exp(-2 mu r)
752
753 /// no factor 1/(2 mu) or square of it included!
754 /// use the Slater fit with an additional term: 1*exp(-0 r^2)
755 static void f12sq_fit(double gamma, double lo, double hi, double eps,
756 Tensor<double>& pcoeff, Tensor<double>& pexpnt, bool prnt) {
757 Tensor<double> coeff1,expnt1, coeff2, expnt2;
758 slater_fit(gamma, lo, hi, eps, coeff1, expnt1, prnt);
759 slater_fit(2.0*gamma, lo, hi, eps, coeff2, expnt2, prnt);
760
761 // check exponents are the same
762 MADNESS_CHECK((expnt1-expnt2).normf()/expnt1.size()<1.e-12);
763
764 // add exponential terms
765 auto coeff=coeff2-2.0*coeff1;
766 pcoeff=Tensor<double>(coeff1.size()+1);
767 pcoeff(Slice(1,-1,1))=coeff(_);
768 pexpnt=Tensor<double>(expnt1.size()+1);
769 pexpnt(Slice(1,-1,1))=expnt1(_);
770
771 // add constant term
772 pcoeff(0l)=1.0;
773 pexpnt(0l)=1.e-10;
774 }
775
776
777 void static bsh_fit_ndim(int ndim, double mu, double lo, double hi, double eps,
778 Tensor<double>& pcoeff, Tensor<double>& pexpnt, bool prnt) {
779
780 if (mu > 0) {
781 // Restrict hi according to the exponential decay
782 double r = -log(4*constants::pi*0.01*eps);
783 r = -log(r * 4*constants::pi*0.01*eps);
784 if (hi > r) hi = r;
785 }
786
787
788 // Determine range of quadrature by estimating when
789 // kernel drops to exp(-100)
790
791 double slo, shi;
792 if (mu > 0) {
793 slo = -0.5*log(4.0*100.0/(mu*mu));
794 slo = -0.5*log(4.0*(slo*ndim - 2.0*slo + 100.0)/(mu*mu));
795 }
796 else {
797 slo = log(eps/hi) - 1.0;
798 }
799 shi = 0.5*log(100.0/(lo*lo));
800
801 // Resolution required for quadrature over s
802 double h = 1.0/(0.2-.50*log10(eps)); // was 0.5 was 0.47
803
804 // Truncate the number of binary digits in h's mantissa
805 // so that rounding does not occur when performing
806 // manipulations to determine the quadrature points and
807 // to limit the number of distinct values in case of
808 // multiple precisions being used at the same time.
809 h = floor(64.0*h)/64.0;
810
811
812 // Round shi/lo up/down to an integral multiple of quadrature points
813 shi = ceil(shi/h)*h;
814 slo = floor(slo/h)*h;
815
816 long npt = long((shi-slo)/h+0.5);
817
818 if (prnt)
819 std::cout << "bsh: mu " << mu << " lo " << lo << " hi " << hi
820 << " eps " << eps << " slo " << slo << " shi " << shi
821 << " npt " << npt << " h " << h << std::endl;
822
823
824 // Compute expansion pruning small coeffs and large exponents
825 Tensor<double> coeff(npt), expnt(npt);
826 int nnpt=0;
827 for (int i=0; i<npt; ++i) {
828 double s = slo + h*(npt-i); // i+1
829 double c = exp(-0.25*mu*mu*exp(-2.0*s)+(ndim-2)*s)*0.5/pow(constants::pi,0.5*ndim);
830 double p = exp(2.0*s);
831 c = c*h;
832 if (c*exp(-p*lo*lo) > eps) {
833 coeff(nnpt) = c;
834 expnt(nnpt) = p;
835 ++nnpt;
836 }
837 }
838 npt = nnpt;
839#if ONE_TERM
840 npt=1;
841 double s=1.0;
842 coeff[0]=1.0;
843 expnt[0] = exp(2.0*s);
844 coeff=coeff(Slice(0,0));
845 expnt=expnt(Slice(0,0));
846 print("only one term in gfit",s,coeff[0],expnt[0]);
847
848#endif
849
850
851 // Prune small exponents from Coulomb fit. Evaluate a gaussian at
852 // the range midpoint, and replace it there with the next most
853 // diffuse gaussian. Then examine the resulting error at the two
854 // end points ... if this error is less than the desired
855 // precision, can discard the diffuse gaussian.
856
857 if (mu == 0.0) {
858 double mid = lo + (hi-lo)*0.5;
859 long i;
860 for (i=npt-1; i>0; --i) {
861 double cnew = coeff[i]*exp(-(expnt[i]-expnt[i-1])*mid*mid);
862 double errlo = coeff[i]*exp(-expnt[i]*lo*lo) -
863 cnew*exp(-expnt[i-1]*lo*lo);
864 double errhi = coeff[i]*exp(-expnt[i]*hi*hi) -
865 cnew*exp(-expnt[i-1]*hi*hi);
866 if (std::max(std::abs(errlo),std::abs(errhi)) > 0.03*eps) break;
867 npt--;
868 coeff[i-1] = coeff[i-1] + cnew;
869 }
870 }
871
872 // Shrink array to correct size
873 coeff = coeff(Slice(0,npt-1));
874 expnt = expnt(Slice(0,npt-1));
875
876
877 if (prnt) {
878 for (int i=0; i<npt; ++i)
879 std::cout << i << " " << coeff[i] << " " << expnt[i] << std::endl;
880
881 long npt = 300;
882 std::cout << " x value" << std::endl;
883 std::cout << " ------------ ---------------------" << std::endl;
884 double step = exp(log(hi/lo)/(npt+1));
885 for (int i=0; i<=npt; ++i) {
886 double r = lo*(pow(step,i+0.5));
887 double test = 0.0;
888 for (int j=0; j<coeff.dim(0); ++j)
889 test += coeff[j]*exp(-r*r*expnt[j]);
890 printf(" %.6e %20.10e\n",r, test);
891 }
892 }
893
894 pcoeff = coeff;
895 pexpnt = expnt;
896 }
897
898 // Returns in q[0..4] int(r^2(n+1)*exp(-alpha*r^2),r=0..R) n=-1,0,1,2
899 static void gaussian_spherical_moments(double alpha, double R, Tensor<double>& q) {
900 q[0] = -(-0.1e1 + exp(-alpha * R*R)) / alpha / 0.2e1;
901 q[1] = (-0.2e1 * R * pow(alpha, 0.3e1 / 0.2e1) + sqrt(constants::pi)
902 * erf(R * sqrt(alpha)) * alpha * exp(alpha * R*R))
903 * pow(alpha, -0.5e1 / 0.2e1) * exp(-alpha * R*R) / 0.4e1;
904 q[2] = -(-0.1e1 + exp(-alpha * R*R) + exp(-alpha * R*R) * alpha * R*R)
905 * pow(alpha, -0.2e1) / 0.2e1;
906 q[3] = -(-0.3e1 * sqrt(constants::pi) * erf(R * sqrt(alpha)) * pow(alpha, 0.2e1)
907 * exp(alpha * R*R) + 0.6e1 * R * pow(alpha, 0.5e1 / 0.2e1)
908 + 0.4e1 * pow(R, 0.3e1) * pow(alpha, 0.7e1 / 0.2e1))
909 * pow(alpha, -0.9e1 / 0.2e1) * exp(-alpha * R*R) / 0.8e1;
910 }
911
912 // Returns in q[0..4] int(r^2(n+1)*exp(-mu*r)/(4*constants::pi*r),r=0..R) n=-1,0,1,2
913 static void bsh_spherical_moments(double mu, double R, Tensor<double>& q) {
914 if (mu == 0.0) {
915 q[0] = R / constants::pi / 0.4e1;
916 q[1] = pow(R, 0.2e1) / constants::pi / 0.8e1;
917 q[2] = pow(R, 0.3e1) / constants::pi / 0.12e2;
918 q[3] = pow(R, 0.4e1) / constants::pi / 0.16e2;
919 }
920 else {
921 q[0] = (exp(mu * R) - 0.1e1) / mu * exp(-mu * R) / constants::pi / 0.4e1;
922 q[1] = -(-exp(mu * R) + 0.1e1 + mu * R) * pow(mu, -0.2e1) / constants::pi
923 * exp(-mu * R) / 0.4e1;
924 q[2] = -(-0.2e1 * exp(mu * R) + 0.2e1 + 0.2e1 * mu * R + R*R *
925 pow(mu, 0.2e1))*pow(mu, -0.3e1) / constants::pi * exp(-mu * R) / 0.4e1;
926 q[3] = -(-0.6e1 * exp(mu * R) + 0.6e1 + 0.6e1 * mu * R + 0.3e1 * R*R
927 * pow(mu, 0.2e1) + pow(R, 0.3e1) * pow(mu, 0.3e1))
928 * pow(mu, -0.4e1) / constants::pi * exp(-mu * R) / 0.4e1;
929 }
930 }
931
932};
933
934
935}
936
937#endif // MADNESS_MRA_GFIT_H__INCLUDED
938
double q(double t)
Definition DKops.h:18
Declares BaseTensor.
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
Tensor< T > coeffs() const
return the coefficients of the fit
Definition gfit.h:369
void print_accuracy(opT op, const double lo, const double hi) const
print coefficients and exponents, and values and errors
Definition gfit.h:466
static GFit InverseRSqFit(double lo, double hi, double eps, bool prnt=false)
return a fit for the inverse-square function 1/r^2
Definition gfit.h:128
Tensor< T > exponents() const
return the exponents of the fit
Definition gfit.h:372
static void prune_small_coefficients(const double eps, const double lo, const double hi, Tensor< double > &coeff, Tensor< double > &expnt, const long first_prunable=1)
Definition gfit.h:378
static GFit GaussFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a (trivial) fit for a single Gauss function
Definition gfit.h:222
GFit()=default
default ctor does nothing
static GFit F2GFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the F2G function
Definition gfit.h:323
GFit(const funcT &f)
ctor taking an isotropic function
Definition gfit.h:456
static void f12_fit(double gamma, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
fit a correlation factor (1- exp(-mu r))
Definition gfit.h:736
static void slater_fit(double gamma, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
fit a Slater function using a sum of Gaussians
Definition gfit.h:662
static void bsh_spherical_moments(double mu, double R, Tensor< double > &q)
Definition gfit.h:913
static GFit BSHFit(double mu, double lo, double hi, double eps, bool prnt=false)
return a fit for the bound-state Helmholtz function
Definition gfit.h:179
static GFit GeneralFit()
return a fit for a general isotropic function
Definition gfit.h:363
Tensor< T > exponents_
the exponents of the expansion f(x) = \sum_m coeffs[m] exp(-exponents[m] * x^2)
Definition gfit.h:493
static GFit FGFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the FG function
Definition gfit.h:289
static void f12sq_fit(double gamma, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
fit a correlation factor f12^2 = (1- exp(-mu r))^2 = 1 - 2 exp(-mu r) + exp(-2 mu r)
Definition gfit.h:755
static GFit F12sqFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the F12^2 correlation factor
Definition gfit.h:266
static void bsh_fit(double mu, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt, bool fix_interval)
fit the function exp(-mu r)/r
Definition gfit.h:504
static void gaussian_spherical_moments(double alpha, double R, Tensor< double > &q)
Definition gfit.h:899
static GFit F12Fit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the F12 correlation factor
Definition gfit.h:245
GFit & operator=(const GFit &other)
assignment operator
Definition gfit.h:96
static GFit SlaterFit(double gamma, double lo, double hi, double eps, bool prnt=false)
return a fit for the Slater function
Definition gfit.h:202
static GFit CoulombFit(double lo, double hi, double eps, bool prnt=false)
return a fit for the Coulomb function
Definition gfit.h:105
static void truncate_mixed_expansion(Tensor< double > &c, Tensor< double > &e, const std::array< LatticeRange, NDIM > &lattice_ranges, const Tensor< double > &cell_width, double lo, double hi_fin, double eps)
Truncate the fit of a kernel that is lattice-summed along some axes.
Definition gfit.h:416
static void bsh_fit_ndim(int ndim, double mu, double lo, double hi, double eps, Tensor< double > &pcoeff, Tensor< double > &pexpnt, bool prnt)
Definition gfit.h:777
GFit(const GFit &other)=default
copy constructor
GFit(OperatorInfo info)
Definition gfit.h:66
Tensor< T > coeffs_
the coefficients of the expansion f(x) = \sum_m coeffs[m] exp(-exponents[m] * x^2)
Definition gfit.h:490
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimensional array.
Definition tensor.h:313
Defines common mathematical and physical constants.
static const double R
Definition csqrt.cc:46
void test(World &world, bool doloadbal=false)
Definition dataloadbal.cc:224
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
static double lo
Definition dirac-hatom.cc:23
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
static double pow(const double *a, const double *b)
Definition lda.h:74
Defines madness::MadnessException for exception handling.
#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_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
constexpr double pi
Mathematical constant .
Definition constants.h:48
Runtime details on the configuration and version of MADNESS.
Definition madness.h:69
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
static const Slice _(0,-1, 1)
OpType
operator types
Definition operatorinfo.h:11
@ OT_FG12
1-exp(-r)
Definition operatorinfo.h:18
@ OT_SLATER
1/r
Definition operatorinfo.h:15
@ OT_GAUSS
exp(-r)
Definition operatorinfo.h:16
@ OT_BSH
(1-exp(-r))^2/r = 1/r + exp(-2r)/r - 2 exp(-r)/r
Definition operatorinfo.h:21
@ OT_INVRSQ
exp(-r)/r
Definition operatorinfo.h:22
@ OT_F12
exp(-r2)
Definition operatorinfo.h:17
@ OT_F212
(1-exp(-r))/r
Definition operatorinfo.h:19
@ OT_G12
indicates the identity
Definition operatorinfo.h:14
@ OT_F2G12
(1-exp(-r))^2
Definition operatorinfo.h:20
void gesv(const Tensor< T > &a, const Tensor< T > &b, Tensor< T > &x)
Solve Ax = b for general A using the LAPACK *gesv routines.
Definition lapack.cc:804
Tensor< double > FunctionDefaults< NDIM >::cell_width
Definition mraimpl.h:3893
bool FunctionDefaults< NDIM >::debug
Definition mraimpl.h:3886
NDIM & f
Definition mra.h:2817
void print(const T &t, Ts &&... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:232
static long abs(long a)
Definition tensor.h:214
const double mu
Definition navstokes_cosines.cc:95
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
Defines simple templates for printing to std::cout "a la Python".
static const double c
Definition relops.cc:10
Declares and implements Slice.
Definition operatorinfo.h:61
Defines and implements most of Tensor.
Prototypes for a partial interface from Tensor to LAPACK.
void e()
Definition test_sig.cc:75
static const double alpha
Definition testcosine.cc:10
double(* exact)(double, double, double)
Definition testfuns.cc:6
std::vector< double > fit(size_t m, size_t n, const std::vector< double > N, const std::vector< double > &f)
Definition testfuns.cc:36
constexpr std::size_t NDIM
Definition testgconv.cc:54
double h(const coord_1d &r)
Definition testgconv.cc:175