mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-23 12:57:20 +01:00
Fixed
- context (and other variables) passing between C-C. Can now passed by value. - removed unnecessary Fortran C-interface; trailing underscore in C-function no longer necessary - renamed C-function and Fortran-interface to C-function from qmckl_sherman_morrison_c_/qmckl_sherman_morrison to qmckl_sherman_morrison/qmckl_sherman_morrison - removed unneccesary artificial pointer variables in qmckl_sherman_morrison and pass them by value.
This commit is contained in:
parent
af54e7a7dc
commit
6437591b66
@ -23,6 +23,7 @@
|
|||||||
int main() {
|
int main() {
|
||||||
qmckl_context context;
|
qmckl_context context;
|
||||||
context = qmckl_context_create();
|
context = qmckl_context_create();
|
||||||
|
const qmckl_context* context_p = &context;
|
||||||
|
|
||||||
qmckl_exit_code rc;
|
qmckl_exit_code rc;
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -88,11 +89,11 @@ int main() {
|
|||||||
#+begin_src c :tangle (eval h_func) :comments org
|
#+begin_src c :tangle (eval h_func) :comments org
|
||||||
qmckl_exit_code qmckl_sherman_morrison(
|
qmckl_exit_code qmckl_sherman_morrison(
|
||||||
const qmckl_context context,
|
const qmckl_context context,
|
||||||
const uint64_t* Dim_p,
|
const uint64_t Dim,
|
||||||
const uint64_t* N_updates_p,
|
const uint64_t N_updates,
|
||||||
const double* Updates,
|
const double* Updates,
|
||||||
const uint64_t* Updates_index,
|
const uint64_t* Updates_index,
|
||||||
const double* breakdown_p,
|
const double breakdown,
|
||||||
double* Slater_inv);
|
double* Slater_inv);
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -103,22 +104,18 @@ int main() {
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "qmckl.h"
|
#include "qmckl.h"
|
||||||
|
|
||||||
qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context,
|
qmckl_exit_code qmckl_sherman_morrison(const qmckl_context context,
|
||||||
const uint64_t* Dim_p,
|
const uint64_t Dim,
|
||||||
const uint64_t* N_updates_p,
|
const uint64_t N_updates,
|
||||||
const double* Updates,
|
const double* Updates,
|
||||||
const uint64_t* Updates_index,
|
const uint64_t* Updates_index,
|
||||||
const double* breakdown_p,
|
const double breakdown,
|
||||||
double* Slater_inv) {
|
double* Slater_inv) {
|
||||||
|
|
||||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||||
return QMCKL_NULL_CONTEXT;
|
return QMCKL_NULL_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t Dim = *Dim_p;
|
|
||||||
const uint64_t N_updates = *N_updates_p;
|
|
||||||
const double breakdown = *breakdown_p;
|
|
||||||
|
|
||||||
double C[Dim];
|
double C[Dim];
|
||||||
double D[Dim];
|
double D[Dim];
|
||||||
|
|
||||||
@ -173,32 +170,6 @@ qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context,
|
|||||||
:FRetType: qmckl_exit_code
|
:FRetType: qmckl_exit_code
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+CALL: generate_c_interface(table=qmckl_sherman_morrison_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
|
|
||||||
|
|
||||||
#+RESULTS:
|
|
||||||
#+begin_src f90 :tangle (eval f) :comments org :exports none
|
|
||||||
integer(c_int32_t) function qmckl_sherman_morrison &
|
|
||||||
(context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) &
|
|
||||||
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) :: Dim
|
|
||||||
integer (c_int64_t) , intent(in) :: N_updates
|
|
||||||
real (c_double ) , intent(in) :: Updates(N_updates*Dim)
|
|
||||||
integer (c_int64_t) , intent(in) :: Updates_index(N_updates)
|
|
||||||
real (c_double ) , intent(in) :: breakdown
|
|
||||||
real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim)
|
|
||||||
|
|
||||||
integer(c_int32_t), external :: qmckl_sherman_morrison_c
|
|
||||||
info = qmckl_sherman_morrison_c &
|
|
||||||
(context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv)
|
|
||||||
|
|
||||||
end function qmckl_sherman_morrison
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+CALL: generate_f_interface(table=qmckl_sherman_morrison_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
|
#+CALL: generate_f_interface(table=qmckl_sherman_morrison_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
|
||||||
|
|
||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
@ -213,11 +184,11 @@ qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context,
|
|||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer (c_int64_t) , intent(in) , value :: context
|
integer (c_int64_t) , intent(in) , value :: context
|
||||||
integer (c_int64_t) , intent(in) :: Dim
|
integer (c_int64_t) , intent(in) , value :: Dim
|
||||||
integer (c_int64_t) , intent(in) :: N_updates
|
integer (c_int64_t) , intent(in) , value :: N_updates
|
||||||
real (c_double ) , intent(in) :: Updates(N_updates*Dim)
|
real (c_double ) , intent(in) :: Updates(N_updates*Dim)
|
||||||
integer (c_int64_t) , intent(in) :: Updates_index(N_updates)
|
integer (c_int64_t) , intent(in) :: Updates_index(N_updates)
|
||||||
real (c_double ) , intent(in) :: breakdown
|
real (c_double ) , intent(in) , value :: breakdown
|
||||||
real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim)
|
real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim)
|
||||||
|
|
||||||
end function qmckl_sherman_morrison
|
end function qmckl_sherman_morrison
|
||||||
@ -271,7 +242,7 @@ assert(Updates1 != NULL);
|
|||||||
assert(Updates_index1 != NULL);
|
assert(Updates_index1 != NULL);
|
||||||
assert(breakdown_p != NULL);
|
assert(breakdown_p != NULL);
|
||||||
assert(Slater_inv1 != NULL);
|
assert(Slater_inv1 != NULL);
|
||||||
rc = qmckl_sherman_morrison(context, Dim_p, N_updates_p, Updates1, Updates_index1, breakdown_p, Slater_inv1);
|
rc = qmckl_sherman_morrison(context, Dim, N_updates1, Updates1, Updates_index1, breakdown, Slater_inv1);
|
||||||
for (unsigned int i = 0; i < Dim; i++) {
|
for (unsigned int i = 0; i < Dim; i++) {
|
||||||
for (unsigned int j = 0; j < Dim; j++) {
|
for (unsigned int j = 0; j < Dim; j++) {
|
||||||
res[i * Dim + j] = 0;
|
res[i * Dim + j] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user