Skip to content

Commit

Permalink
Remove std::cout
Browse files Browse the repository at this point in the history
  • Loading branch information
terasakisatoshi committed Dec 17, 2024
1 parent 1ae23ca commit 375ef5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
28 changes: 9 additions & 19 deletions include/sparseir/basis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace sparseir {
template <typename S, typename K=LogisticKernel>
class FiniteTempBasis : public AbstractBasis<S> {
public:
std::shared_ptr<K> kernel;
K kernel;
std::shared_ptr<SVEResult<K>> sve_result;
double accuracy;
double beta;
Expand All @@ -174,7 +174,7 @@ class FiniteTempBasis : public AbstractBasis<S> {
PiecewiseLegendreFTVector<S> uhat_full;

FiniteTempBasis(double beta, double omega_max, double epsilon,
K &kernel, SVEResult<K> sve_result, int max_size = -1)
K kernel, SVEResult<K> sve_result, int max_size = -1)
{
if (sve_result.s.size() == 0) {
throw std::runtime_error("SVE result sve_result.s is empty");
Expand All @@ -188,10 +188,10 @@ class FiniteTempBasis : public AbstractBasis<S> {
"Frequency cutoff omega_max must be non-negative");
}
this->beta = beta;
this->kernel = std::make_shared<K>(kernel);
this->kernel = kernel;
this->sve_result = std::make_shared<SVEResult<K>>(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);
Expand All @@ -205,14 +205,7 @@ class FiniteTempBasis : public AbstractBasis<S> {
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<double, 3> udata3d = sve_result.u.get_data();
PiecewiseLegendrePolyVector uhat_base_full =
Expand Down Expand Up @@ -259,7 +252,7 @@ class FiniteTempBasis : public AbstractBasis<S> {
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<K> &getSVEResult() const { return sve_result; }
Expand All @@ -268,7 +261,7 @@ class FiniteTempBasis : public AbstractBasis<S> {
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
Expand Down Expand Up @@ -297,15 +290,12 @@ class FiniteTempBasis : public AbstractBasis<S> {
// Rescale function
FiniteTempBasis<S, K> 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<S, K>(
new_beta,
new_omega_max,
std::numeric_limits<double>::quiet_NaN(),
*kernel,
kernel,
*sve_result,
static_cast<int>(s.size())
);
Expand Down
11 changes: 3 additions & 8 deletions test/basis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<sparseir::LogisticKernel> sve_result = sparseir::compute_sve(kernel);

using FermKernel = sparseir::FiniteTempBasis<sparseir::Fermionic, sparseir::LogisticKernel>;
Expand Down Expand Up @@ -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") {
Expand All @@ -102,6 +97,6 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") {
sparseir::FiniteTempBasis<sparseir::Fermionic, sparseir::LogisticKernel> basis(beta, omega_max, epsilon, sparseir::LogisticKernel(beta * omega_max));
sparseir::FiniteTempBasis<sparseir::Fermionic, sparseir::LogisticKernel> 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);
}
}
2 changes: 0 additions & 2 deletions test/sve.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(lmax - 1));
Expand Down

0 comments on commit 375ef5d

Please sign in to comment.