Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 68 additions & 23 deletions ALPS3_MIGRATION_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,29 +361,62 @@ and Boost.Math in `legendre_convert`.

### 2.3 Code fixes

* Fix B1 through B20 (§1.6), including B7b. B21 (logging convention and verbosity) can go here or into a later step; it changes the CLI regression references on purpose.
* Moved here from 2.2 (they change the CLI references on purpose): replace
`boost::diagnostic_information` by `e.what()` (with B1), add a `SEED`
parameter for the bootstrap (B10), and delete the commented-out ublas and
LAPACK-bindings code.
* `legendre_convert` (decided 2026-09-24), in this order:
1. Add regression cases for `legendre_convert` first (it has no tests), with
references from the current Boost build, like the `kk` cases in 2.2.
2. Replace Boost.Random by `<random>`. The `mt19937` engine gives identical
numbers; the normal variates differ (different algorithm), which is
harmless because the error estimate is seeded from the clock.
3. Replace `boost::math::factorial` by a product (only small arguments
occur).
4. Replace `boost::math::legendre_p` by the standard three-term recurrence.
`std::legendre` is not an option: libc++ (AppleClang) does not implement
the C++17 special math functions.
Keep `boost::math::sph_bessel` (also missing in libc++; our own version
would need careful checking at large l and argument) and `program_options`
(no standard equivalent). B5, B6 and B7 change reachable behavior, so each gets its own commit with a before/after test.
* Remove all `using namespace boost::numeric;` lines, `#include <alps/config.hpp>`, dead commented-out ublas and lapack-bindings code, and the unused `alps::cast`.
* Make `eigen_hdf5.hpp`/`eigen_lapack.hpp` functions `inline`, or move them into `.cpp` files (B8).
* Use `Eigen::Index` for loop indices (B14). Consider `BDCSVD` in place of `JacobiSVD` (B11); that one is a numerics change and needs checking against the references.
* Keep the `MaxEntSimulation` public getters stable, because the tests use them.
Grouped by what each item does to the regression references (agreed
2026-09-24). One PR per group, in this order, each with a Copilot review.
Already done elsewhere: B2, B3 (2.1), B7 (`xi_bose_bugfix`), B20 (Pade removed).

**2.3A: no change to results** (references must stay bit-identical)

**Done 2026-09-24.** All Maxent-owned code and utilities build with
`-Wall -Wextra -Wpedantic -Werror`; the fast and full regression suites remain
unchanged. A text-input regression covers trailing blank lines.

* Fix all compiler warnings (44 at the start of 2.3): B14 (`std::size_t` vs
`Eigen::Index` loops), B12 (member initialization order), unused variables,
misleading indentation, B13 (deprecated `params::get_origin_name()`; the
default `BASENAME` must not change). Then turn on `MAXENT_WERROR` in the `dev`
preset.
* B8: make the functions in `eigen_hdf5.hpp`/`eigen_lapack.hpp` `inline`.
* B4: make the size check in `Backcont::max_error` unconditional, avoiding an
out-of-bounds access in every build type.
* B5, B6: remove the unreachable kernel branches.
* B9: the data-file reading loop (`while (datstream)` reads past EOF); same
results for valid files, plus a test with trailing blank lines.
* Remove the commented-out ublas and LAPACK-bindings code, `<alps/config.hpp>`
includes and the unused `alps::cast`.

**2.3B: `legendre_convert`** (decided 2026-09-24), in this order:

1. Add regression cases for `legendre_convert` first (it has no tests), with
references from the current Boost build, like the `kk` cases in 2.2.
2. Replace Boost.Random by `<random>`. The `mt19937` engine gives identical
numbers; the normal variates differ (different algorithm), which is
harmless because the error estimate is seeded from the clock.
3. Replace `boost::math::factorial` by a product (only small arguments occur).
4. Replace `boost::math::legendre_p` by the standard three-term recurrence.
`std::legendre` is not an option: libc++ (AppleClang) does not implement the
C++17 special math functions.

Keep `boost::math::sph_bessel` (also missing in libc++; our own version would
need careful checking at large l and argument) and `program_options` (no
standard equivalent).

**2.3C: command-line behavior** (updates the CLI references on purpose)

* B1: non-zero exit code on errors, together with `boost::diagnostic_information`
→ `e.what()` (moved here from 2.2).
* B16: accept `half-lorentzian` as well as `half lorentzian`, and show the real
`CUT` default in `--help.grids`.
* B10: a `SEED` parameter for the bootstrap errors (moved here from 2.2).

**2.3D: numerical changes** (each its own commit and `REFERENCE_CHANGES.md` entry)

* B7b: time-bosonic kernel: use the ω→0 limit only at ω = 0.
* B15: remove the `float` casts in the log grid.
* B11 (optional): `BDCSVD` instead of `JacobiSVD`; measure against the
references before deciding.

Keep the `MaxEntSimulation` public getters stable, because the tests use them.

### 2.4 Hygiene and CI

Expand All @@ -406,6 +439,17 @@ This is the last task of step 2, still on ALPSCore:
2. **HDF5 seam:** move all archive access into `maxent_io_hdf5.{hpp,cpp}`, with functions such as `write_vector(path, Eigen::VectorXd)`, `read_vector(path)` and `write_params(...)`. Nothing else includes `<alps/hdf5...>`.
3. Tests use `std::filesystem::temp_directory_path()` in place of `alps::temporary_filename`.

### 2.6 Physics and algorithms (after 2.3–2.5)

Moved out of 2.3 (2026-09-24) because they are physics or algorithm changes
rather than cleanup; each needs its own decision:

* B17: Legendre bosonic kernel (currently the fermionic formula).
* B18: default grid when `OMEGA_MIN=0` (change the default, or warn).
* B19: minimizer divergence (step-size control or a trust region).
* B21: logging convention and verbosity (issue #46).
* B22: performance of the core at large NFREQ.

**Step 2 acceptance:**

* Configures with CMake 3.22 through 4.x.
Expand Down Expand Up @@ -640,3 +684,4 @@ make -j8 && ctest # 6/6 executables, 35 cases pass, ~9 s
| 2026-09-23 | 2.x | Pade removed (D7), on branch `modernize/remove-pade`: `pade/` (13 files: 6 built, 5 unbuilt alternatives, header, CMake), `MAXENT_BUILD_PADE`, and the README section. It required GMP (`mpf_class`, 256-bit default precision) and did not compile (B20). |
| 2026-09-24 | 2.2 | Step 2.2 done on `modernize/step2.2`: kk regression cases, kk spline, closed-form Legendre kernel (GSL removed), Boost utilities → std. No reference changed; 41/41 tests. ALPSCore#668 merged (GoogleTest 1.18, not installed, CMake 3.16). Found B22 (performance). |
| 2026-09-24 | sync | Synced with ALPSCore `master` `560ae112` (#669: C++14 required and default, ALPSCore compiled with exactly `ALPS_CXX_STD`, Boost.Math dependency removed; #670: Doxygen removed). Maxent `d529a14` against it (installed as C++14, Boost 1.88): configures without `Boost_DIR`, compiles as C++17, 41/41 tests, regression unchanged (only the known Legendre rounding-level differences from 2.2). Note: build ALPSCore in a fresh build directory; an old one keeps a stale compiler identification that Maxent's configure then rejects. |
| 2026-09-24 | 2.3A | Warning cleanup and no-output-change fixes complete: Eigen index types, initializer order, unused/deprecated code, inline HDF5/LAPACK helpers, unconditional size validation, unreachable kernel branches, robust three- and five-column text-file extraction, and dead bindings/config code removed. The dev preset enables `MAXENT_WERROR`; 44/44 Release tests pass including full regression, and the LAPACK build is warning-free. |
5 changes: 4 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
"name": "dev",
"displayName": "Debug",
"inherits": "base",
"cacheVariables": {"CMAKE_BUILD_TYPE": "Debug"}
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"MAXENT_WERROR": "ON"
}
},
{
"name": "asan",
Expand Down
2 changes: 1 addition & 1 deletion legendre_convert/legendre_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ double GtBoot(vector_type gl_in, void *arg){
//************************
int main(int argc, char**argv){
namespace po = boost::program_options;
double beta,c1,c2,c3;
double beta,c1,c2;
int lmax,numConvergence,maxit,maxn;
bool backcontinue = false,enforceTailOff = false,enforceErrCheck=true,continueMatsubara=false;
std::string input_gtau_filename,gl_filename;
Expand Down
6 changes: 2 additions & 4 deletions src/eigen_hdf5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#pragma once
#include <alps/hdf5/archive.hpp>
#include <alps/utilities/cast.hpp>
#include <Eigen/Core>
#include <algorithm>

Expand All @@ -32,7 +31,7 @@ namespace alps {
if (value.size()) {
std::vector<std::size_t> first(get_extent(value[0]));
if (true)
for(std::size_t i=1;i<value.size();i++) {
for(Eigen::Index i=1;i<value.size();i++) {
std::vector<std::size_t> size(get_extent(value[i]));
if (
first.size() != size.size()
Expand All @@ -46,15 +45,14 @@ namespace alps {
}
};
}
void save(
inline void save(
archive &ar
, std::string const & path
, Eigen::VectorXd &value
, std::vector<std::size_t> size = std::vector<std::size_t>()
, std::vector<std::size_t> chunk =std::vector<std::size_t>()
, std::vector<std::size_t> offset = std::vector<std::size_t>()
) {
using alps::cast;
if (ar.is_group(path))
ar.delete_group(path);
if (is_continuous<Eigen::VectorXd>::value && value.size() == 0)
Expand Down
4 changes: 1 addition & 3 deletions src/eigen_lapack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ extern "C" void dgesvd_( const char* jobu, const char* jobvt,
///performs a SVD on input matrix K
/// returns K = U (S) V^T where S is a vector of the diagonal values of
/// matrix Sigma
void lapack_svd(matrix_type &K, vector_type &S, matrix_type &Vt, matrix_type &U){

/*boost::numeric::bindings::lapack::gesvd('S', 'S', Kt, S, U_, Vt_);*/
inline void lapack_svd(matrix_type &K, vector_type &S, matrix_type &Vt, matrix_type &U){
//use 'S' for thin U,Vt matrices
char jobu = 'S';
char jobvt = 'S';
Expand Down
5 changes: 2 additions & 3 deletions src/maxent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(int argc,const char** argv)

std::string basename;
if(parms.defaulted("BASENAME")){
basename = alps::fs::remove_extensions(parms.get_origin_name()) + ".out";
basename = alps::fs::remove_extensions(alps::origin_name(parms)) + ".out";
parms["BASENAME"] = basename;
}
else
Expand Down Expand Up @@ -151,7 +151,7 @@ int main(int argc,const char** argv)
ofstream_ spec_file;
spec_file.open((basename+".varspec.dat").c_str());
spec_file << "#omega mean_maxspec stdev_maxspec mean_avspec stdev_avspec" <<std::endl;
for (std::size_t i=0; i<omega_grid.size(); ++i)
for (Eigen::Index i=0; i<omega_grid.size(); ++i)
spec_file << omega_grid(i)
<< " " << mean_max(i) << " " << stdev_max(i)
<< " " << mean_av(i) << " " << stdev_av(i)
Expand All @@ -171,4 +171,3 @@ int main(int argc,const char** argv)
std::cerr << "Caught Exception" << boost::current_exception_diagnostic_information();
}
}

4 changes: 1 addition & 3 deletions src/maxent_backcont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ vector_type Backcont::backcontinue(const vector_type &A){
}
double Backcont::max_error(const vector_type &y1, const vector_type &y2){
double max_err = 0.0;
#ifdef NDEBUG
if(y1.size() != y2.size()){
throw std::runtime_error("backcont vector size mismatch!");
}
#endif
for(int i=0;i<y1.size();i++){
for(Eigen::Index i=0;i<y1.size();i++){
double delta = std::abs(y1(i)-y2(i));
if(delta>max_err){
max_err = delta;
Expand Down
1 change: 0 additions & 1 deletion src/maxent_backcont.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#pragma once
#include "maxent.hpp"
#include <alps/config.hpp> // needed to set up correct bindings

///This class contains necessities to analytically continue a
//real function to the imaginary axis
Expand Down
Loading
Loading