#include #include #include #include #include #include struct fun { typedef std::complex result_type; typedef double argument_type; /*double f(double eps, double tau, double beta) const { bool s = (tau>0); tau = (s ? tau : beta + tau); return (s ? 1 : -1 ) * exp( - eps* (tau)) / (1 + exp(- beta *eps)); }*/ std::complex operator()(double x, double y) const { const double pi = acos(-1); const double beta = 10.0; const double epsi = 0.1; double tau = x-y; bool s = (tau>0); tau = (s ? tau : beta + tau); double r = epsi + tau/beta *(1-2*epsi); return - 2*(pi/beta)/ std::sin ( pi *r); //return - 0.5*(f(0.12, x-y, beta) + f(0.43,x-y,beta) ); //+ f(-0.7,x-y,beta)); } }; template void assert_close( T1 const & A, T2 const & B, double precision) { std::cerr << " assert_close "<< A << " "<< B<< " "<< std::abs(A-B) <<" "<< precision << std::endl; if ( std::abs(A-B) > precision) TRIQS_RUNTIME_ERROR<<"assert_close error : "< D; std::complex det_old,detratio; test() : f(), D(f,100) {} void check() { #ifndef PRINT_ALL std::cerr << "det = " << D.determinant() << " == " << std::complex(determinant(D.matrix()))<< std::endl; #else std::cerr << "det = " << D.determinant() << " == " << std::complex(determinant(D.matrix()))<< std::endl << D.inverse_matrix() << D.matrix() << triqs::arrays::matrix>(inverse(D.matrix()))<< std::endl; std::cerr << "det_old = " << det_old << "detratio = "<< detratio<< " determin "<< D.determinant() <0) detratio = D.try_remove(RNG(s),RNG(s)); break; case 2: std::cerr << " Insert2" << std::endl; x = RNG(10.0); x1 = RNG(10.0); y = RNG(10.0); y1 = RNG(10.0); i0 = RNG(s); i1 = RNG(s+1); j0 = RNG(s); j1 = RNG(s+1); if ((i0 !=i1)&& (j0!=j1)) { detratio = D.try_insert2(i0,i1,j0,j1, x,x1,y,y1); } else do_something = false; break; case 3: std::cerr << " Remove2" << std::endl; if (D.size()>=2) { i0 = RNG(s); i1 = RNG(s); j0 = RNG(s); j1 = RNG(s); if ((i0 !=i1)&& (j0!=j1)) { detratio = D.try_remove2(i0,i1,j0,j1); } else do_something = false; } break; default : TRIQS_RUNTIME_ERROR <<" TEST INTERNAL ERROR" ; }; if (do_something) { if (std::abs(detratio*det_old)> PRECISION) { D.complete_operation(); if (D.size() >0) check(); } else { std::cerr << " reject since new det is = " << std::abs(detratio*det_old)<