From 800f541660152bfd5dd6e605a1e7f758ea0be3fb Mon Sep 17 00:00:00 2001 From: SatoshiTerasaki Date: Tue, 17 Dec 2024 08:59:33 +0900 Subject: [PATCH] Increase tests --- include/sparseir/basis.hpp | 27 +++++++++++++++++---------- test/basis.cxx | 9 ++++++--- test/poly.cxx | 2 -- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/sparseir/basis.hpp b/include/sparseir/basis.hpp index c8b51a7..2bb56c4 100644 --- a/include/sparseir/basis.hpp +++ b/include/sparseir/basis.hpp @@ -185,7 +185,7 @@ class FiniteTempBasis : public AbstractBasis { } FiniteTempBasis(double beta, double omega_max, double epsilon, - K& kernel) + K kernel) { SVEResult sve_result = compute_sve(kernel, epsilon); int max_size = -1; @@ -461,17 +461,24 @@ class FiniteTempBasis : public AbstractBasis { } }; -/* -inline std::pair, FiniteTempBasis> finite_temp_bases( double beta, double omega_max, double -epsilon = std::numeric_limits::quiet_NaN() -) +inline std::pair, + FiniteTempBasis> + finite_temp_bases( + double beta, double omega_max, + double epsilon, + SVEResult sve_result + ) { - return std::make_pair>(beta, -omega_max, epsilon), FiniteTempBasis(beta, omega_max, -epsilon); + LogisticKernel kernel(beta * omega_max); + std::cout << "sve_result.s.size() = " << sve_result.s.size() << std::endl; + auto basis_f = FiniteTempBasis( + beta, omega_max, epsilon, kernel, sve_result); + std::cout << "basis_f.s.size() = " << basis_f.s.size() << std::endl; + auto basis_b = FiniteTempBasis( + beta, omega_max, epsilon, kernel, sve_result); + std::cout << "basis_b.s.size() = " << basis_b.s.size() << std::endl; + return std::make_pair(basis_f, basis_b); } -*/ inline std::pair, FiniteTempBasis> diff --git a/test/basis.cxx b/test/basis.cxx index 3f8eae9..b84623b 100644 --- a/test/basis.cxx +++ b/test/basis.cxx @@ -49,7 +49,7 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") { using FermKernel = sparseir::FiniteTempBasis; using BosKernel = sparseir::FiniteTempBasis; - //std::pair bases = sparseir::finite_temp_bases(beta, omega_max, epsilon, sve_result); + std::pair bases = sparseir::finite_temp_bases(beta, omega_max, epsilon, sve_result); /* sparseir::FiniteTempBasisSet bs(beta, omega_max, epsilon, sve_result); @@ -72,7 +72,6 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") { double beta = 1e-3; double omega_max = 1e-3; double epsilon = 1e-100; - /* sparseir::FiniteTempBasis basis(beta, omega_max, epsilon, sparseir::LogisticKernel(beta * omega_max)); @@ -80,12 +79,16 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") { sparseir::compute_sve(sparseir::LogisticKernel(beta * omega_max)); double scale = std::sqrt(beta / 2.0 * omega_max); + /* + std::cout << "scale = " << scale << std::endl; // Ensure the correct function or member is used for singular values Eigen::VectorXd scaled_s_eigen = sve.s * scale; + std::cout << "scaled_s_eigen " << scaled_s_eigen << std::endl; + std::cout << "basis.s.size()" << basis.s.size() << std::endl; REQUIRE(basis.s.isApprox(scaled_s_eigen)); // Access accuracy as a member variable if it's not a function - REQUIRE(basis.accuracy == sve.s(sve.s.size() - 1) / sve.s[0]); + REQUIRE(basis.accuracy == sve.s(sve.s.size() - 1) / sve.s(0)); */ } diff --git a/test/poly.cxx b/test/poly.cxx index 9db1cb3..49712de 100644 --- a/test/poly.cxx +++ b/test/poly.cxx @@ -331,7 +331,6 @@ TEST_CASE("Roots") // Find roots Eigen::VectorXd roots = pwlp.roots(); - /* // Expected roots from Julia Eigen::VectorXd expected_roots(3); expected_roots << 0.1118633448586015, 0.4999999999999998, 0.8881366551413985; @@ -348,5 +347,4 @@ TEST_CASE("Roots") // Verify these are actually roots REQUIRE(std::abs(pwlp(roots[i])) < 1e-10); } - */ }