Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
q3::SerialSubspaceDiagonalizer Class Reference

#include <serial.hpp>

+ Inheritance diagram for q3::SerialSubspaceDiagonalizer:

Public Member Functions

std::string name () const override
 
int solve (int basis_size, Complex *hamiltonian_matrix, Complex *overlap_matrix, Real *eigenvalues, Complex *eigenvector_matrix, bool is_gamma_only=false) override
 
- Public Member Functions inherited from q3::SubspaceDiagonalizer
virtual ~SubspaceDiagonalizer ()=default
 
virtual bool is_collective () const
 

Detailed Description

Definition at line 16 of file serial.hpp.

Member Function Documentation

◆ name()

std::string q3::SerialSubspaceDiagonalizer::name ( ) const
inlineoverridevirtual

Implements q3::SubspaceDiagonalizer.

Definition at line 148 of file serial.hpp.

◆ solve()

int q3::SerialSubspaceDiagonalizer::solve ( int  basis_size,
Complex *  hamiltonian_matrix,
Complex *  overlap_matrix,
Real *  eigenvalues,
Complex *  eigenvector_matrix,
bool  is_gamma_only = false 
)
inlineoverridevirtual

Solve the generalized eigenvalue problem: H * C = S * C * E

Parameters
basis_sizeDimension of the subspace (matrix size).
hamiltonian_matrixProjected Hamiltonian (destroyed/overwritten). May be the same buffer as eigenvector_matrix: every implementation reads it whole before it writes any eigenvector, which is what lets the caller keep one copy of H rather than two.
overlap_matrixProjected overlap (destroyed/overwritten).
eigenvaluesOutput eigenvalues (size basis_size).
eigenvector_matrixOutput eigenvectors (basis_size x basis_size).
Returns
0 on success, non-zero on failure.

Gamma-only: H_sub and S_sub are real symmetric matrices, so dsygv solves them and its eigenvectors come out real.

Both are packed to real in place rather than into copies of their own: the real part of complex entry i is written to double entry i, which lies inside complex entry i/2 – already read – so a forward pass is safe, and the eigenvectors are expanded back to complex by a backward pass for the same reason. The matrices are the caller's to overwrite, and the Hamiltonian is usually the eigenvector buffer itself.

Non-gamma: use zhegv for complex Hermitian matrices. It leaves the eigenvectors where the Hamiltonian was, so the Hamiltonian goes into the eigenvector buffer – unless the caller already handed the same buffer as both.

Implements q3::SubspaceDiagonalizer.

Definition at line 18 of file serial.hpp.

References q3::lapack::dsygv_(), and q3::lapack::zhegv_().


The documentation for this class was generated from the following file: