1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-03 20:54:09 +01:00

Merge pull request #59 from GianFree/compute_asymp_jasb_c

qmckl_compute_asymp_jasb_f to C
This commit is contained in:
vijay 2022-02-04 10:22:47 +01:00 committed by GitHub
commit db27b0614d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,6 @@ these factors along with their derivatives.
(org-babel-lob-ingest "../tools/lib.org")
#+end_src
#+begin_src c :tangle (eval h_private_func)
#ifndef QMCKL_JASTROW_HPF
#define QMCKL_JASTROW_HPF
@ -1304,43 +1303,55 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc
end function qmckl_compute_asymp_jasb_f
#+end_src
#+begin_src c :comments org :tangle (eval c) :noweb yes
qmckl_exit_code qmckl_compute_asymp_jasb (
const qmckl_context context,
const int64_t bord_num,
const double* bord_vector,
const double rescale_factor_kappa_ee,
double* const asymp_jasb ) {
double kappa_inv, x, asym_one;
kappa_inv = 1.0 / rescale_factor_kappa_ee;
if (context == QMCKL_NULL_CONTEXT){
return QMCKL_INVALID_CONTEXT;
}
if (bord_num <= 0) {
return QMCKL_INVALID_ARG_2;
}
asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1] * kappa_inv);
asymp_jasb[0] = asym_one;
asymp_jasb[1] = 0.5 * asym_one;
for (int i = 0 ; i <= 1; ++i) {
x = kappa_inv;
for (int p = 1; p < bord_num; ++p){
x = x * kappa_inv;
asymp_jasb[i] = asymp_jasb[i] + bord_vector[p + 1] * x;
}
}
return QMCKL_SUCCESS;
}
#+end_src
#+CALL: generate_c_header(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
#+RESULTS:
#+BEGIN_src c :tangle (eval h_func) :comments org
#+begin_src c :tangle (eval h_func) :comments org
qmckl_exit_code qmckl_compute_asymp_jasb (
const qmckl_context context,
const int64_t bord_num,
const double* bord_vector,
const double rescale_factor_kappa_ee,
double* const asymp_jasb );
#+END_src
#+end_src
#+CALL: generate_c_interface(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
#+RESULTS:
#+BEGIN_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_compute_asymp_jasb &
(context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
integer (c_int64_t) , intent(in) , value :: context
integer (c_int64_t) , intent(in) , value :: bord_num
real (c_double ) , intent(in) :: bord_vector(bord_num + 1)
real (c_double ) , intent(in) , value :: rescale_factor_kappa_ee
real (c_double ) , intent(out) :: asymp_jasb(2)
integer(c_int32_t), external :: qmckl_compute_asymp_jasb_f
info = qmckl_compute_asymp_jasb_f &
(context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb)
end function qmckl_compute_asymp_jasb
#+END_src
*** Test
#+name: asymp_jasb
#+begin_src python :results output :exports none :noweb yes