From 375ef5dbb3d3bfc0c96ad5be0109f5a7b1b411c5 Mon Sep 17 00:00:00 2001 From: SatoshiTerasaki Date: Tue, 17 Dec 2024 19:14:35 +0900 Subject: [PATCH] Remove std::cout --- include/sparseir/basis.hpp | 28 +++++++++------------------- test/basis.cxx | 11 +++-------- test/sve.cxx | 2 -- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/include/sparseir/basis.hpp b/include/sparseir/basis.hpp index 794bc41..a840693 100644 --- a/include/sparseir/basis.hpp +++ b/include/sparseir/basis.hpp @@ -163,7 +163,7 @@ namespace sparseir { template class FiniteTempBasis : public AbstractBasis { public: - std::shared_ptr kernel; + K kernel; std::shared_ptr> sve_result; double accuracy; double beta; @@ -174,7 +174,7 @@ class FiniteTempBasis : public AbstractBasis { PiecewiseLegendreFTVector uhat_full; FiniteTempBasis(double beta, double omega_max, double epsilon, - K &kernel, SVEResult sve_result, int max_size = -1) + K kernel, SVEResult sve_result, int max_size = -1) { if (sve_result.s.size() == 0) { throw std::runtime_error("SVE result sve_result.s is empty"); @@ -188,10 +188,10 @@ class FiniteTempBasis : public AbstractBasis { "Frequency cutoff omega_max must be non-negative"); } this->beta = beta; - this->kernel = std::make_shared(kernel); + this->kernel = kernel; this->sve_result = std::make_shared>(sve_result); - double wmax = this->kernel->lambda_ / beta; + double wmax = this->kernel.lambda_ / beta; auto part_result = sve_result.part(epsilon, max_size); PiecewiseLegendrePolyVector u_ = std::get<0>(part_result); @@ -205,14 +205,7 @@ class FiniteTempBasis : public AbstractBasis { this->accuracy = sve_result.s(s_.size() - 1) / sve_result_s0; } - std::cout << "ypower = " << this->kernel->ypower() << std::endl; - std::cout << "wmax = " << wmax << std::endl; - std::cout << "beta = " << beta << std::endl; - std::cout << "s_ = " << s_ << std::endl; - std::cout << "sve_result_s0 = " << sve_result_s0 << std::endl; - std::cout << "sve_result.s.size() = " << sve_result.s.size() << std::endl; - - this->s = (std::sqrt(beta / 2 * wmax) * std::pow(wmax, -(this->kernel->ypower()))) * s_; + this->s = (std::sqrt(beta / 2 * wmax) * std::pow(wmax, -(this->kernel.ypower()))) * s_; Eigen::Tensor udata3d = sve_result.u.get_data(); PiecewiseLegendrePolyVector uhat_base_full = @@ -259,7 +252,7 @@ class FiniteTempBasis : public AbstractBasis { double get_accuracy() const { return accuracy; } // Getter for ωmax - double get_wmax() const { return kernel->lambda_ / beta; } + double get_wmax() const { return kernel.lambda_ / beta; } // Getter for SVEResult const SVEResult &getSVEResult() const { return sve_result; } @@ -268,7 +261,7 @@ class FiniteTempBasis : public AbstractBasis { const K &getKernel() const { return kernel; } // Getter for Λ - double Lambda() const { return kernel->lambda_; } + double Lambda() const { return kernel.lambda_; } // Default τ sampling points Eigen::VectorXd defaultTauSamplingPoints() const @@ -297,15 +290,12 @@ class FiniteTempBasis : public AbstractBasis { // Rescale function FiniteTempBasis rescale(double new_beta) const { - std::cout << "Rescaling..." << std::endl; - std::cout << "kernel->lambda_ = " << kernel->lambda_ << std::endl; - double new_omega_max = kernel->lambda_ / new_beta; - std::cout << "new_omega_max = " << new_omega_max << std::endl; + double new_omega_max = kernel.lambda_ / new_beta; return FiniteTempBasis( new_beta, new_omega_max, std::numeric_limits::quiet_NaN(), - *kernel, + kernel, *sve_result, static_cast(s.size()) ); diff --git a/test/basis.cxx b/test/basis.cxx index 9d57f45..0206b54 100644 --- a/test/basis.cxx +++ b/test/basis.cxx @@ -44,9 +44,6 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") { sparseir::LogisticKernel kernel(beta * omega_max); // Specify the template argument for SVEResult - std::cout << "kernel = " << kernel.lambda_ << std::endl; - std::cout << "kernel.ypower() = " << kernel.ypower() << std::endl; - sparseir::SVEResult sve_result = sparseir::compute_sve(kernel); using FermKernel = sparseir::FiniteTempBasis; @@ -85,12 +82,10 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") { double scale = std::sqrt(beta / 2.0 * omega_max); // Ensure the correct function or member is used for singular values Eigen::VectorXd scaled_s_eigen = sve.s * scale; - std::cout << "basis.s = " << basis.s << std::endl; - std::cout << "sve.s = " << sve.s << std::endl; REQUIRE(basis.s.size() == sve.s.size()); - //REQUIRE(basis.s.isApprox(scaled_s_eigen)); + 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(std::abs(basis.accuracy - sve.s(sve.s.size() - 1) / sve.s(0)) < 1e-10); } SECTION("Rescaling test") { @@ -102,6 +97,6 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") { sparseir::FiniteTempBasis basis(beta, omega_max, epsilon, sparseir::LogisticKernel(beta * omega_max)); sparseir::FiniteTempBasis rescaled_basis = basis.rescale(2.0); REQUIRE(rescaled_basis.sve_result->s.size() == basis.sve_result->s.size()); - //REQUIRE(rescaled_basis.get_wmax() == 6.0); + REQUIRE(rescaled_basis.get_wmax() == 6.0); } } diff --git a/test/sve.cxx b/test/sve.cxx index da142fb..1072d3b 100644 --- a/test/sve.cxx +++ b/test/sve.cxx @@ -250,9 +250,7 @@ TEST_CASE("sve.cpp", "[truncate]") auto s = std::get<1>(truncated); auto v = std::get<2>(truncated); - std::cout << "test" << std::endl; auto sveresult = sve.postprocess(u, s, v); - std::cout << "test2" << std::endl; REQUIRE(sveresult.u.size() == sveresult.s.size()); REQUIRE(sveresult.s.size() == sveresult.v.size()); REQUIRE(sveresult.s.size() <= static_cast(lmax - 1));