ConjugateGradientSolver works with Eigen types#539
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the solver utilities so ConjugateGradientSolver (and related solver infrastructure) can operate directly on Eigen vector/matrix types by ensuring the required freestanding linear-algebra helpers are discoverable via ADL and by avoiding hard member-function requirements in generic tile interfaces.
Changes:
- Add Eigen-specific specializations/tests to validate
ConjugateGradientSolver<Eigen::VectorXd, ...>behavior. - Constrain several non-intrusive tile interface helpers (
abs_min/abs_max/dot/inner_product,clone) with SFINAE so they don’t break ADL-based resolution for non-TiledArray types (e.g., Eigen). - Add missing Eigen freestanding adapters (
clone,volume,abs_min,abs_max) and switch solver numeric type deduction toTiledArray::detail::numeric_t.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/solvers.cpp | Adds an Eigen-based conjugate gradient unit test and supporting helpers. |
| src/TiledArray/tile_op/tile_interface.h | Adds SFINAE constraints so these helpers only participate when the type has the corresponding member function. |
| src/TiledArray/tile_interface/clone.h | Adds SFINAE constraint to the member-based TiledArray::clone to avoid blocking ADL for non-TiledArray types. |
| src/TiledArray/math/solvers/diis.h | Uses numeric_t<D> for value type deduction (Eigen compatibility) and includes type traits. |
| src/TiledArray/math/solvers/conjgrad.h | Uses numeric_t<D>, updates docs to abs_min/abs_max, and makes DIIS usage compile-time gated. |
| src/TiledArray/math/linalg/basic.h | Adds Eigen freestanding adapters (clone, volume, abs_min, abs_max) needed by solver requirements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| constexpr bool use_diis = false; | ||
| [[maybe_unused]] DIIS<D> diis; |
There was a problem hiding this comment.
use_diis is a compile-time false, but DIIS<D> diis is still constructed unconditionally (including allocating B_ in DIIS::init()), even though it can never be used. Consider constructing DIIS only inside an if constexpr (use_diis) block (or via a lazily-emplaced optional) so the disabled DIIS path has zero runtime overhead.
a3ac387 to
f4c5c40
Compare
No description provided.