mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-10 21:18:37 +01:00
- Added documentation to helper functions
- Removed redundant #include qmckl.h - Commented out the #ifdef DEBUG ... #endif blocks - Changed Sherman-Morrison break-down check to use qmckl_exit_code qmckl_sherman_morrison_threshold double* const thresh ). #25
This commit is contained in:
parent
f325f4feda
commit
7b2a8caeab
@ -21,8 +21,6 @@ Low- and high-level functions that use the Sherman-Morrison and Woodbury matrix
|
|||||||
#define THRESHOLD 1e-3
|
#define THRESHOLD 1e-3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "qmckl.h"
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
qmckl_context context;
|
qmckl_context context;
|
||||||
context = qmckl_context_create();
|
context = qmckl_context_create();
|
||||||
@ -31,7 +29,7 @@ int main() {
|
|||||||
|
|
||||||
* Sherman-Morrison Helper Functions
|
* Sherman-Morrison Helper Functions
|
||||||
|
|
||||||
[TODO: FMJC] Add doc
|
Helper functions that are used by the Sherman-Morrison-Woodbury kernels. These functions should only be used in the context of these kernels.
|
||||||
|
|
||||||
** ~qmckl_sherman_morrison_threshold~
|
** ~qmckl_sherman_morrison_threshold~
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
@ -40,7 +38,7 @@ int main() {
|
|||||||
:FRetType: double precision
|
:FRetType: double precision
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
[TODO: FMJC] Add doc
|
This function is used to set the threshold value that is used in the kernels to determine if a matrix is invertable or not. In the Sherman-Morrison kernels this is determined by comparing the denominator in the Sherman-Morrison formula to the value set in threshold. If the value is smaller than the threshold value it means the matrix is not invertable. In the Woodbury kernels the threshold value is compared with the value of the determinant of the update matrix.
|
||||||
|
|
||||||
#+NAME: qmckl_sherman_morrison_threshold_args
|
#+NAME: qmckl_sherman_morrison_threshold_args
|
||||||
| double | thresh | out | Threshold |
|
| double | thresh | out | Threshold |
|
||||||
@ -87,9 +85,9 @@ end function qmckl_sherman_morrison_threshold_f
|
|||||||
// Sherman-Morrison-Woodbury break-down threshold
|
// Sherman-Morrison-Woodbury break-down threshold
|
||||||
static double qmckl_shreman_morrison_threshold(double* const threshold) {
|
static double qmckl_shreman_morrison_threshold(double* const threshold) {
|
||||||
*threshold = THRESHOLD;
|
*threshold = THRESHOLD;
|
||||||
#ifdef DEBUG
|
// #ifdef DEBUG
|
||||||
std::cerr << "Break-down threshold set to: " << threshold << std::endl;
|
// std::cerr << "Break-down threshold set to: " << threshold << std::endl;
|
||||||
#endif
|
// #endif
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -216,9 +214,9 @@ qmckl_exit_code qmckl_sherman_morrison_c(const qmckl_context context,
|
|||||||
const double* Updates,
|
const double* Updates,
|
||||||
const uint64_t* Updates_index,
|
const uint64_t* Updates_index,
|
||||||
double * Slater_inv) {
|
double * Slater_inv) {
|
||||||
#ifdef DEBUG
|
// #ifdef DEBUG
|
||||||
std::cerr << "Called qmckl_sherman_morrison with " << N_updates << " updates" << std::endl;
|
// std::cerr << "Called qmckl_sherman_morrison with " << N_updates << " updates" << std::endl;
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
double C[Dim];
|
double C[Dim];
|
||||||
double D[Dim];
|
double D[Dim];
|
||||||
@ -239,8 +237,10 @@ qmckl_exit_code qmckl_sherman_morrison_c(const qmckl_context context,
|
|||||||
|
|
||||||
// Denominator
|
// Denominator
|
||||||
double den = 1 + C[Updates_index[l] - 1];
|
double den = 1 + C[Updates_index[l] - 1];
|
||||||
if (fabs(den) < threshold) {
|
double const thresh;
|
||||||
return false;
|
qmckl_sherman_morrison_threshold(&thresh);
|
||||||
|
if (fabs(den) < thresh) {
|
||||||
|
return QMCKL_FAILURE;
|
||||||
}
|
}
|
||||||
double iden = 1 / den;
|
double iden = 1 / den;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user