Quantum 3xplorer (Q3)
Loading...
Searching...
No Matches
init.hpp
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* SubspaceDiagonalizer — interface for small-matrix diagonalization.
5
*
6
* Used inside iterative solvers (Davidson, Lanczos) to diagonalize the
7
* projected Hamiltonian and overlap matrices in the basis subspace.
8
* Also used by direct solvers for the final diagonalization step.
9
*
10
* Implementations provide serial (LAPACK) or distributed (ScaLAPACK) variants.
11
*/
12
13
#include <string>
14
#include <vector>
15
16
#include "
layer_0_core/types/init.hpp
"
17
18
namespace
q3
{
19
20
class
SubspaceDiagonalizer
{
21
public
:
22
virtual
~SubspaceDiagonalizer
() =
default
;
23
24
/**
25
* Solve the generalized eigenvalue problem: H * C = S * C * E
26
*
27
* @param basis_size Dimension of the subspace (matrix size).
28
* @param hamiltonian_matrix Projected Hamiltonian (destroyed/overwritten).
29
* May be the same buffer as eigenvector_matrix:
30
* every implementation reads it whole before it
31
* writes any eigenvector, which is what lets the
32
* caller keep one copy of H rather than two.
33
* @param overlap_matrix Projected overlap (destroyed/overwritten).
34
* @param eigenvalues Output eigenvalues (size basis_size).
35
* @param eigenvector_matrix Output eigenvectors (basis_size x basis_size).
36
* @return 0 on success, non-zero on failure.
37
*/
38
virtual
int
solve
(
int
basis_size,
39
Complex
* hamiltonian_matrix,
40
Complex
* overlap_matrix,
41
Real
* eigenvalues,
42
Complex
* eigenvector_matrix,
43
bool
is_gamma_only =
false
) = 0;
44
45
/**
46
* Whether solve() is a collective operation over the process group.
47
*
48
* Collective solvers (ScaLAPACK) require EVERY rank of the group to call
49
* solve() — gating the call on one rank deadlocks the group — and return
50
* redundant results on all ranks, so no post-solve broadcast is needed.
51
* Non-collective solvers (serial LAPACK) may be called on the group root
52
* only, with results broadcast afterwards.
53
*/
54
virtual
bool
is_collective
()
const
{
55
return
false
;
56
}
57
58
virtual
std::string
name
()
const
= 0;
59
};
60
61
}
// namespace q3
q3::SubspaceDiagonalizer
Definition
init.hpp:20
q3::SubspaceDiagonalizer::~SubspaceDiagonalizer
virtual ~SubspaceDiagonalizer()=default
q3::SubspaceDiagonalizer::is_collective
virtual bool is_collective() const
Definition
init.hpp:54
q3::SubspaceDiagonalizer::name
virtual std::string name() const =0
q3::SubspaceDiagonalizer::solve
virtual int solve(int basis_size, Complex *hamiltonian_matrix, Complex *overlap_matrix, Real *eigenvalues, Complex *eigenvector_matrix, bool is_gamma_only=false)=0
init.hpp
q3
Definition
q3_core_api.hpp:33
q3::Real
double Real
Definition
type_aliases.hpp:20
q3::Complex
std::complex< double > Complex
Definition
type_aliases.hpp:21
src
layer_4_computation
diagonalizer
planewave
subspace
init.hpp
Generated by
1.9.8