Skip to content

Commit

Permalink
Merge pull request #59 from GianFree/compute_asymp_jasb_c
Browse files Browse the repository at this point in the history
qmckl_compute_asymp_jasb_f to C
  • Loading branch information
v1j4y committed Feb 4, 2022
2 parents eb34535 + 3a727b7 commit db27b06
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions org/qmckl_jastrow.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1304,42 +1303,54 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc
end function qmckl_compute_asymp_jasb_f
#+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
qmckl_exit_code qmckl_compute_asymp_jasb (
#+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 );
#+END_src
double* const asymp_jasb ) {

double kappa_inv, x, asym_one;

#+CALL: generate_c_interface(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name"))
kappa_inv = 1.0 / rescale_factor_kappa_ee;

#+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)
if (context == QMCKL_NULL_CONTEXT){
return QMCKL_INVALID_CONTEXT;
}

use, intrinsic :: iso_c_binding
implicit none
if (bord_num <= 0) {
return QMCKL_INVALID_ARG_2;
}

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)
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;

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)
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
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 function qmckl_compute_asymp_jasb
#+END_src

*** Test
#+name: asymp_jasb
Expand Down

0 comments on commit db27b06

Please sign in to comment.