Skip to content

Commit

Permalink
Increase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
terasakisatoshi committed Dec 16, 2024
1 parent ec0986f commit 800f541
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
27 changes: 17 additions & 10 deletions include/sparseir/basis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class FiniteTempBasis : public AbstractBasis<S> {
}

FiniteTempBasis(double beta, double omega_max, double epsilon,
K& kernel)
K kernel)
{
SVEResult<K> sve_result = compute_sve<K>(kernel, epsilon);
int max_size = -1;
Expand Down Expand Up @@ -461,17 +461,24 @@ class FiniteTempBasis : public AbstractBasis<S> {
}
};

/*
inline std::pair<FiniteTempBasis<Fermionic, LogisticKernel>, FiniteTempBasis<Bosonic,
LogisticKernel>> finite_temp_bases( double beta, double omega_max, double
epsilon = std::numeric_limits<double>::quiet_NaN()
)
inline std::pair<FiniteTempBasis<Fermionic, LogisticKernel>,
FiniteTempBasis<Bosonic, LogisticKernel>>
finite_temp_bases(
double beta, double omega_max,
double epsilon,
SVEResult<LogisticKernel> sve_result
)
{
return std::make_pair<FiniteTempBasis<Fermionic, LogisticKernel>>(beta,
omega_max, epsilon), FiniteTempBasis<Bosonic, LogisticKernel>(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<Fermionic, LogisticKernel>(
beta, omega_max, epsilon, kernel, sve_result);
std::cout << "basis_f.s.size() = " << basis_f.s.size() << std::endl;
auto basis_b = FiniteTempBasis<Bosonic, LogisticKernel>(
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<Fermionic, LogisticKernel>,
FiniteTempBasis<Bosonic, LogisticKernel>>
Expand Down
9 changes: 6 additions & 3 deletions test/basis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") {
using FermKernel = sparseir::FiniteTempBasis<sparseir::Fermionic, sparseir::LogisticKernel>;
using BosKernel = sparseir::FiniteTempBasis<sparseir::Bosonic, sparseir::LogisticKernel>;

//std::pair<FermKernel, BosKernel> bases = sparseir::finite_temp_bases(beta, omega_max, epsilon, sve_result);
std::pair<FermKernel, BosKernel> bases = sparseir::finite_temp_bases(beta, omega_max, epsilon, sve_result);
/*
sparseir::FiniteTempBasisSet<sparseir::LogisticKernel> bs(beta, omega_max, epsilon, sve_result);
Expand All @@ -72,20 +72,23 @@ TEST_CASE("FiniteTempBasis consistency tests", "[basis]") {
double beta = 1e-3;
double omega_max = 1e-3;
double epsilon = 1e-100;
/*
sparseir::FiniteTempBasis<sparseir::Fermionic, sparseir::LogisticKernel>
basis(beta, omega_max, epsilon,
sparseir::LogisticKernel(beta * omega_max));
sparseir::SVEResult<sparseir::LogisticKernel> sve =
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));
*/
}

Expand Down
2 changes: 0 additions & 2 deletions test/poly.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -348,5 +347,4 @@ TEST_CASE("Roots")
// Verify these are actually roots
REQUIRE(std::abs(pwlp(roots[i])) < 1e-10);
}
*/
}

0 comments on commit 800f541

Please sign in to comment.