Skip to content

ConjugateGradientSolver works with Eigen types#539

Merged
evaleev merged 1 commit intomasterfrom
evaleev/feature/cg-with-eigen-matrices
Mar 2, 2026
Merged

ConjugateGradientSolver works with Eigen types#539
evaleev merged 1 commit intomasterfrom
evaleev/feature/cg-with-eigen-matrices

Conversation

@evaleev
Copy link
Member

@evaleev evaleev commented Mar 2, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to TiledArray::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.

Comment on lines +77 to +78
constexpr bool use_diis = false;
[[maybe_unused]] DIIS<D> diis;
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@evaleev evaleev force-pushed the evaleev/feature/cg-with-eigen-matrices branch from a3ac387 to f4c5c40 Compare March 2, 2026 05:03
@evaleev evaleev merged commit 4f811c2 into master Mar 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants