Skip to content

Commit d1208c7

Browse files
committed
remove unnecessary statistic parameter from convolution-related functions and deprecate previous signatures
1 parent fae598a commit d1208c7

File tree

3 files changed

+71
-29
lines changed

3 files changed

+71
-29
lines changed

c++/cppdlr/dlr_dyson.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace cppdlr {
6262
auto g0c = itops_ptr->vals2coefs(g0); // DLR coefficients of free Green's function
6363

6464
// Get matrix of convolution by free Green's function
65-
g0mat = itops_ptr->convmat(beta, Fermion, g0c, time_order);
65+
g0mat = itops_ptr->convmat(beta, g0c, time_order);
6666

6767
// Get right hand side of Dyson equation
6868
if constexpr (std::floating_point<Ht>) { // If h is real scalar, rhs is a vector
@@ -86,7 +86,7 @@ namespace cppdlr {
8686
* \note Hamiltonian must either be a symmetric matrix, a Hermitian matrix,
8787
* or a real scalar.
8888
*/
89-
dyson_it(double beta, imtime_ops itops, Ht const &h, bool time_order) : dyson_it(beta, itops, h, 0, time_order) {};
89+
dyson_it(double beta, imtime_ops itops, Ht const &h, bool time_order) : dyson_it(beta, itops, h, 0, time_order){};
9090

9191
/**
9292
* @brief Solve Dyson equation for given self-energy
@@ -111,7 +111,7 @@ namespace cppdlr {
111111
// Obtain Dyson equation system matrix I - G0 * Sig, where G0 and Sig are the
112112
// matrices of convolution by the free Green's function and self-energy,
113113
// respectively.
114-
auto sysmat = make_regular(nda::eye<double>(r * norb) - g0mat * itops_ptr->convmat(beta, Fermion, sigc, time_order));
114+
auto sysmat = make_regular(nda::eye<double>(r * norb) - g0mat * itops_ptr->convmat(beta, sigc, time_order));
115115

116116
// Factorize system matrix
117117
auto ipiv = nda::vector<int>(r * norb);

c++/cppdlr/dlr_imtime.hpp

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,10 @@ namespace cppdlr {
304304
* @return Values of h = f * g on DLR imaginary time grid
305305
* */
306306
template <nda::MemoryArray T, nda::Scalar S = nda::get_value_t<T>>
307-
typename T::regular_type convolve(double beta, statistic_t statistic, T const &fc, T const &gc, bool time_order = false) const {
307+
typename T::regular_type convolve(double beta, T const &fc, T const &gc, bool time_order = false) const {
308308

309309
if (r != fc.shape(0) || r != gc.shape(0)) throw std::runtime_error("First dim of input arrays must be equal to DLR rank r.");
310310

311-
// TODO: implement bosonic case and remove
312-
if (statistic == 0) throw std::runtime_error("imtime_ops::convolve not yet implemented for bosonic Green's functions.");
313-
314311
// Initialize convolution, if it hasn't been done already
315312
if (!time_order & hilb.empty()) { convolve_init(); }
316313
if (time_order & thilb.empty()) { tconvolve_init(); }
@@ -353,6 +350,22 @@ namespace cppdlr {
353350
}
354351
}
355352

353+
/**
354+
* @brief Deprecated overload of convolve method
355+
*
356+
* This version includes an unused extra parameter for backward
357+
* compatibility.
358+
*
359+
* @deprecated Use convolve(beta, fc, gc, time_order) instead; this works for
360+
* both fermionic and bosonic functions.
361+
*/
362+
template <nda::MemoryArray T, nda::Scalar S = nda::get_value_t<T>>
363+
[[deprecated("Use convolve(beta, fc, gc, time_order) instead.")]] typename T::regular_type
364+
convolve(double beta, statistic_t statistic, T const &fc, T const &gc, bool time_order = false) const {
365+
(void)statistic; // Unused parameter, kept for backward compatibility
366+
return convolve(beta, fc, gc, time_order);
367+
}
368+
356369
/**
357370
* @brief Compute convolution of two imaginary time Green's functions,
358371
* given matrix of convolution by one of them
@@ -449,7 +462,7 @@ namespace cppdlr {
449462
* r*norb2 x r*norb3 matrix, or a block r x 1 matrix of norb2 x norb3 blocks.
450463
* */
451464
template <nda::MemoryArray T, nda::Scalar S = nda::get_value_t<T>>
452-
nda::matrix<S> convmat(double beta, statistic_t statistic, T const &fc, bool time_order = false) const {
465+
nda::matrix<S> convmat(double beta, T const &fc, bool time_order = false) const {
453466

454467
int n, m;
455468

@@ -464,11 +477,27 @@ namespace cppdlr {
464477
}
465478

466479
auto fconv = nda::matrix<S, nda::C_layout>(n, m); // Matrix of convolution by f
467-
convmat_inplace(nda::matrix_view<S, nda::C_layout>(fconv), beta, statistic, fc, time_order);
480+
convmat_inplace(nda::matrix_view<S, nda::C_layout>(fconv), beta, fc, time_order);
468481

469482
return fconv;
470483
}
471484

485+
/**
486+
* @brief Deprecated overload of convmat method
487+
*
488+
* This version includes an unused extra parameter for backward
489+
* compatibility.
490+
*
491+
* @deprecated Use convmat(beta, fc, time_order) instead; this works for both
492+
* fermionic and bosonic functions.
493+
*/
494+
template <nda::MemoryArray T, nda::Scalar S = nda::get_value_t<T>>
495+
[[deprecated("Use convmat(beta, fc, time_order) instead.")]] nda::matrix<S> convmat(double beta, statistic_t statistic, T const &fc,
496+
bool time_order = false) const {
497+
(void)statistic; // Unused parameter, kept for backward compatibility
498+
return convmat(beta, fc, time_order);
499+
}
500+
472501
/**
473502
* @brief Compute matrix of convolution by an imaginary time Green's function
474503
* in place
@@ -519,13 +548,10 @@ namespace cppdlr {
519548
* r*norb2 x r*norb3 matrix, or a block r x 1 matrix of norb2 x norb3 blocks.
520549
* */
521550
template <nda::MemoryArray T, nda::Scalar S = nda::get_value_t<T>>
522-
void convmat_inplace(nda::matrix_view<S, nda::C_layout> fconv, double beta, statistic_t statistic, T const &fc, bool time_order = false) const {
551+
void convmat_inplace(nda::matrix_view<S, nda::C_layout> fconv, double beta, T const &fc, bool time_order = false) const {
523552

524553
if (r != fc.shape(0)) throw std::runtime_error("First dim of input array must be equal to DLR rank r.");
525554

526-
// TODO: implement bosonic case and remove
527-
if (statistic == 0) throw std::runtime_error("imtime_ops::convmat not yet implemented for bosonic Green's functions.");
528-
529555
// Initialize convolution, if it hasn't been done already
530556
if (!time_order & hilb.empty()) { convolve_init(); }
531557
if (time_order & thilb.empty()) { tconvolve_init(); }
@@ -622,6 +648,22 @@ namespace cppdlr {
622648
}
623649
}
624650

651+
/**
652+
* @brief Deprecated overload of convmat_inplace method
653+
*
654+
* This version includes an unused extra parameter for backward
655+
* compatibility.
656+
*
657+
* @deprecated Use convmat_inplace(fconv, beta, fc, time_order) instead; this
658+
* works for both fermionic and bosonic functions.
659+
*/
660+
template <nda::MemoryArray T, nda::Scalar S = nda::get_value_t<T>>
661+
[[deprecated("Use convmat_inplace(fconv, beta, fc, time_order) instead.")]] void
662+
convmat_inplace(nda::matrix_view<S, nda::C_layout> fconv, double beta, statistic_t statistic, T const &fc, bool time_order = false) const {
663+
(void)statistic; // Unused parameter, kept for backward compatibility
664+
return convmat_inplace(fconv, beta, fc, time_order);
665+
}
666+
625667
/**
626668
* @brief Compute inner product of two imaginary time Green's functions
627669
*

test/c++/imtime_ops.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,13 @@ TEST(imtime_ops, convolve_scalar_real) {
492492
auto gc = itops.vals2coefs(g);
493493

494494
// Get convolution and time-ordered convolution of f and g directly
495-
auto h = itops.convolve(beta, Fermion, fc, gc);
496-
auto ht = itops.convolve(beta, Fermion, fc, gc, TIME_ORDERED);
495+
auto h = itops.convolve(beta, fc, gc);
496+
auto ht = itops.convolve(beta, fc, gc, TIME_ORDERED);
497497

498498
// Get convolution and time-ordered convolution of f and g by first forming
499499
// matrix of convolution by f and then applying it to g
500-
auto h2 = itops.convolve(itops.convmat(beta, Fermion, fc), g);
501-
auto ht2 = itops.convolve(itops.convmat(beta, Fermion, fc, TIME_ORDERED), g);
500+
auto h2 = itops.convolve(itops.convmat(beta, fc), g);
501+
auto ht2 = itops.convolve(itops.convmat(beta, fc, TIME_ORDERED), g);
502502

503503
// Check that the two methods give the same result
504504
EXPECT_LT(max_element(abs(h - h2)), 1e-14);
@@ -577,13 +577,13 @@ TEST(imtime_ops, convolve_scalar_cmplx) {
577577
auto gc = itops.vals2coefs(g);
578578

579579
// Get convolution and time-ordered convolution of f and g directly
580-
auto h = itops.convolve(beta, Fermion, fc, gc);
581-
auto ht = itops.convolve(beta, Fermion, fc, gc, TIME_ORDERED);
580+
auto h = itops.convolve(beta, fc, gc);
581+
auto ht = itops.convolve(beta, fc, gc, TIME_ORDERED);
582582

583583
// Get convolution and time-ordered convolution of f and g by first forming
584584
// matrix of convolution by f and then applying it to g
585-
auto h2 = itops.convolve(itops.convmat(beta, Fermion, fc), g);
586-
auto ht2 = itops.convolve(itops.convmat(beta, Fermion, fc, TIME_ORDERED), g);
585+
auto h2 = itops.convolve(itops.convmat(beta, fc), g);
586+
auto ht2 = itops.convolve(itops.convmat(beta, fc, TIME_ORDERED), g);
587587

588588
// Check that the two methods give the same result
589589
EXPECT_LT(max_element(abs(h - h2)), 1e-14);
@@ -667,11 +667,11 @@ TEST(imtime_ops, convolve_matrix_real) {
667667
auto gc = itops.vals2coefs(g);
668668

669669
// Get convolution and time-ordered convolution of f and g directly
670-
auto h = itops.convolve(beta, Fermion, fc, gc);
671-
auto ht = itops.convolve(beta, Fermion, fc, gc, TIME_ORDERED);
670+
auto h = itops.convolve(beta, fc, gc);
671+
auto ht = itops.convolve(beta, fc, gc, TIME_ORDERED);
672672

673-
auto h2 = itops.convolve(itops.convmat(beta, Fermion, fc), g);
674-
auto ht2 = itops.convolve(itops.convmat(beta, Fermion, fc, TIME_ORDERED), g);
673+
auto h2 = itops.convolve(itops.convmat(beta, fc), g);
674+
auto ht2 = itops.convolve(itops.convmat(beta, fc, TIME_ORDERED), g);
675675

676676
// Check that the two methods give the same result
677677
EXPECT_LT(max_element(abs(h - h2)), 1e-14);
@@ -758,13 +758,13 @@ TEST(imtime_ops, convolve_matrix_cmplx) {
758758
auto gc = itops.vals2coefs(g);
759759

760760
// Get convolution and time-ordered convolution of f and g directly
761-
auto h = itops.convolve(beta, Fermion, fc, gc);
762-
auto ht = itops.convolve(beta, Fermion, fc, gc, TIME_ORDERED);
761+
auto h = itops.convolve(beta, fc, gc);
762+
auto ht = itops.convolve(beta, fc, gc, TIME_ORDERED);
763763

764764
// Get convolution and time-ordered convolution of f and g by first forming
765765
// matrix of convolution by f and then applying it to g
766-
auto h2 = itops.convolve(itops.convmat(beta, Fermion, fc), g);
767-
auto ht2 = itops.convolve(itops.convmat(beta, Fermion, fc, TIME_ORDERED), g);
766+
auto h2 = itops.convolve(itops.convmat(beta, fc), g);
767+
auto ht2 = itops.convolve(itops.convmat(beta, fc, TIME_ORDERED), g);
768768

769769
// Check that the two methods give the same result
770770
EXPECT_LT(max_element(abs(h - h2)), 1e-14);

0 commit comments

Comments
 (0)