1#ifndef MADNESS_JACOBI_H
2#define MADNESS_JACOBI_H
21 int i, j,
k, iter, nrot;
22 double tolmin = std::sqrt(n) * 5.0e-16, tol = 0.05;
27 A(i,j) =
A(j,i) = 0.5*(
A(i,j) +
A(j,i));
35 double daii = std::fabs(
A(i,i));
36 maxd = std::max(maxd,daii);
41 double * __restrict__ ai = &A(i,0); \
42 double * __restrict__ aj = &A(j,0); \
43 for (k=0; k<n; k++) { \
53 double * __restrict__ ai = &A(0,i); \
54 double * __restrict__ aj = &A(0,j); \
55 for (k=0; k<n*n; k+=n) { \
63 for (iter=0; iter<5000; iter++) {
67 for (j=i+1; j<n; j++) {
68 if (set[i] != set[j]) {
72 double daij = std::fabs(aij);
74 maxdaij = std::max(maxdaij,daij/maxd);
76 if (daij > tol*maxd) {
78 double ds = std::fabs(s);
79 if (daij > (tolmin*ds)) {
82 if ((tolmin*daij) > ds) {
83 c = s = 1.0/std::sqrt(2.);
87 double u = 0.25/std::sqrt(0.25+t*t);
116 A(j,i) =
A(i,j) = 0.0;
118 maxd = std::max(maxd,std::fabs(
A(i,i)));
119 maxd = std::max(maxd,std::fabs(
A(j,j)));
126 if (nrot == 0 && tol <= tolmin)
break;
127 tol = std::min(tol,maxdaij*1
e-1);
129 tol = std::max(tol,tolmin);
132 printf(
"Jacobi iteration did not converge in 5000 passes\n");
Definition test_ar.cc:118
A tensor is a multidimension array.
Definition tensor.h:317
static double u(double r, double c)
Definition he.cc:20
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
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void jacobi(Tensor< double > &A, Tensor< double > &V, const std::vector< int > &set)
Definition jacobi.h:13
Defines simple templates for printing to std::cout "a la Python".
static const double c
Definition relops.cc:10
static const long k
Definition rk.cc:44
static double V(const coordT &r)
Definition tdse.cc:288
Defines and implements most of Tensor.
void e()
Definition test_sig.cc:75