Skip to content

Commit 3835a26

Browse files
authored
Docs: update hpsi_func requirements (#5190)
1 parent b5125de commit 3835a26

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

source/module_hsolver/diago_david.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,10 @@ void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& p
11491149
/**
11501150
* @brief Performs iterative diagonalization using the David algorithm.
11511151
*
1152+
* @warning Please see docs of `HPsiFunc` for more information.
1153+
* @warning Please adhere strictly to the requirements of the function pointer
1154+
* @warning for the hpsi mat-vec interface; it may seem counterintuitive.
1155+
*
11521156
* @tparam T The type of the elements in the matrix.
11531157
* @tparam Device The device type (CPU or GPU).
11541158
* @param hpsi_func The function object that computes the matrix-blockvector product H * psi.

source/module_hsolver/diago_david.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,23 @@ class DiagoDavid : public DiagH<T, Device>
3636
* This function type is used to define a matrix-blockvector operator H.
3737
* For eigenvalue problem HX = λX or generalized eigenvalue problem HX = λSX,
3838
* this function computes the product of the Hamiltonian matrix H and a blockvector X.
39+
*
40+
* Called as follows:
41+
* hpsi(X, HX, nvec, dim, id_start, id_end)
42+
* Result is stored in HX.
43+
* HX = H * X[id_start:id_end]
3944
*
40-
* @param[out] X Pointer to input blockvector of type `T*`.
41-
* @param[in] HX Pointer to output blockvector of type `T*`.
45+
* @param[out] X Head address of input blockvector of type `T*`.
46+
* @param[in] HX Where to write output blockvector of type `T*`.
4247
* @param[in] nvec Number of eigebpairs, i.e. number of vectors in a block.
4348
* @param[in] dim Dimension of matrix.
4449
* @param[in] id_start Start index of blockvector.
4550
* @param[in] id_end End index of blockvector.
51+
*
52+
* @warning HX is the exact address to store output H*X[id_start:id_end];
53+
* @warning while X is the head address of input blockvector, \b without offset.
54+
* @warning Calling function should pass X and HX[offset] as arguments,
55+
* @warning where offset is usually id_start * leading dimension.
4656
*/
4757
using HPsiFunc = std::function<void(T*, T*, const int, const int, const int, const int)>;
4858

0 commit comments

Comments
 (0)