1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-01 02:45:43 +02:00

Change point API to make it consistent for Python

This commit is contained in:
Anthony Scemama 2022-05-20 19:57:01 +02:00
parent bd299126c1
commit ce1aeb324d
4 changed files with 23 additions and 9 deletions

View File

@ -101,10 +101,10 @@ point = []
for x in linspace[0]:
for y in linspace[1]:
for z in linspace[2]:
point += [x, y, z]
point += [ [x, y, z] ]
#point = np.array(point)
qmckl.set_point(context, 'N', point, len(point)/3)
point = np.array(point)
qmckl.set_point(context, 'N', len(point), point)
#+end_src
#+RESULTS:

View File

@ -718,7 +718,7 @@ qmckl_set_electron_coord(qmckl_context context,
ctx->electron.coord_old = ctx->electron.coord_new ;
qmckl_exit_code rc;
rc = qmckl_set_point(context, transp, coord, size_max/3);
rc = qmckl_set_point(context, transp, size_max/3, coord, size_max);
assert (rc == QMCKL_SUCCESS);
ctx->electron.coord_new = ctx->point.coord ;

View File

@ -263,8 +263,9 @@ end interface
#+begin_src c :comments org :tangle (eval h_func)
qmckl_exit_code qmckl_set_point (qmckl_context context,
const char transp,
const int64_t num,
const double* coord,
const int64_t num);
const int64_t size_max);
#+end_src
Copy a sequence of ~num~ points $(x,y,z)$ into the context.
@ -273,14 +274,22 @@ qmckl_exit_code qmckl_set_point (qmckl_context context,
qmckl_exit_code
qmckl_set_point (qmckl_context context,
const char transp,
const int64_t num,
const double* coord,
const int64_t num)
const int64_t size_max)
{
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
return QMCKL_NULL_CONTEXT;
}
if (size_max < 3*num) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_4,
"qmckl_set_point",
"Array too small");
}
if (transp != 'N' && transp != 'T') {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
@ -349,7 +358,7 @@ qmckl_set_point (qmckl_context context,
#+begin_src f90 :comments org :tangle (eval fh_func) :noweb yes
interface
integer(c_int32_t) function qmckl_set_point(context, &
transp, coord, num) bind(C)
transp, num, coord, size_max) bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
@ -358,6 +367,7 @@ interface
character(c_char) , intent(in) , value :: transp
real (c_double ) , intent(in) :: coord(*)
integer (c_int64_t) , intent(in) , value :: num
integer (c_int64_t) , intent(in) , value :: size_max
end function
end interface
#+end_src
@ -380,7 +390,7 @@ double coord3[point_num*3];
rc = qmckl_get_point (context, 'N', coord2, (point_num*3));
assert(rc == QMCKL_NOT_PROVIDED);
rc = qmckl_set_point (context, 'N', coord, point_num);
rc = qmckl_set_point (context, 'N', point_num, coord, (point_num*3));
assert(rc == QMCKL_SUCCESS);
int64_t n;
@ -404,7 +414,7 @@ for (int64_t i=0 ; i<point_num ; ++i) {
assert( coord[3*i+2] == coord2[i+point_num*2] );
}
rc = qmckl_set_point (context, 'T', coord2, point_num);
rc = qmckl_set_point (context, 'T', point_num, coord2, (point_num*3));
assert(rc == QMCKL_SUCCESS);
rc = qmckl_get_point (context, 'N', coord3, (point_num*3));

View File

@ -48,6 +48,10 @@ import_array();
/* Include typemaps generated by the process_header.py script */
%include "qmckl_include.i"
/* Handle properly get_point */
/* exception.i is a generic (language-independent) module */
%include "exception.i"