mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-08-25 14:41:46 +02:00
Merge branch 'add-python-api' of github.com:TREX-CoE/qmckl into add-python-api
This commit is contained in:
commit
3886a2c337
@ -1058,11 +1058,11 @@ E_L = KE + PE
|
||||
*** Get
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_func) :noweb yes
|
||||
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double* const local_energy);
|
||||
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double* const local_energy, const int64_t size_max);
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const local_energy) {
|
||||
qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const local_energy, const int64_t size_max) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return QMCKL_NULL_CONTEXT;
|
||||
@ -1086,8 +1086,14 @@ qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double * const loc
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
size_t sze = ctx->electron.walk_num * sizeof(double);
|
||||
memcpy(local_energy, ctx->local_energy.e_local, sze);
|
||||
const int64_t sze = ctx->electron.walk_num;
|
||||
if (size_max < sze) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_3,
|
||||
"qmckl_get_local_energy",
|
||||
"input array too small");
|
||||
}
|
||||
memcpy(local_energy, ctx->local_energy.e_local, sze * sizeof(double));
|
||||
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
@ -1292,7 +1298,7 @@ end function qmckl_compute_local_energy_f
|
||||
|
||||
double local_energy[walk_num];
|
||||
|
||||
rc = qmckl_get_local_energy(context, &(local_energy[0]));
|
||||
rc = qmckl_get_local_energy(context, &(local_energy[0]), walk_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
#+end_src
|
||||
|
Loading…
Reference in New Issue
Block a user