mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-07-03 09:56:10 +02:00
Change point API to make it consistent for Python
This commit is contained in:
parent
bd299126c1
commit
ce1aeb324d
|
@ -101,10 +101,10 @@ point = []
|
||||||
for x in linspace[0]:
|
for x in linspace[0]:
|
||||||
for y in linspace[1]:
|
for y in linspace[1]:
|
||||||
for z in linspace[2]:
|
for z in linspace[2]:
|
||||||
point += [x, y, z]
|
point += [ [x, y, z] ]
|
||||||
|
|
||||||
#point = np.array(point)
|
point = np.array(point)
|
||||||
qmckl.set_point(context, 'N', point, len(point)/3)
|
qmckl.set_point(context, 'N', len(point), point)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
|
|
|
@ -718,7 +718,7 @@ qmckl_set_electron_coord(qmckl_context context,
|
||||||
ctx->electron.coord_old = ctx->electron.coord_new ;
|
ctx->electron.coord_old = ctx->electron.coord_new ;
|
||||||
|
|
||||||
qmckl_exit_code rc;
|
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);
|
assert (rc == QMCKL_SUCCESS);
|
||||||
|
|
||||||
ctx->electron.coord_new = ctx->point.coord ;
|
ctx->electron.coord_new = ctx->point.coord ;
|
||||||
|
|
|
@ -263,8 +263,9 @@ end interface
|
||||||
#+begin_src c :comments org :tangle (eval h_func)
|
#+begin_src c :comments org :tangle (eval h_func)
|
||||||
qmckl_exit_code qmckl_set_point (qmckl_context context,
|
qmckl_exit_code qmckl_set_point (qmckl_context context,
|
||||||
const char transp,
|
const char transp,
|
||||||
|
const int64_t num,
|
||||||
const double* coord,
|
const double* coord,
|
||||||
const int64_t num);
|
const int64_t size_max);
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Copy a sequence of ~num~ points $(x,y,z)$ into the context.
|
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_exit_code
|
||||||
qmckl_set_point (qmckl_context context,
|
qmckl_set_point (qmckl_context context,
|
||||||
const char transp,
|
const char transp,
|
||||||
|
const int64_t num,
|
||||||
const double* coord,
|
const double* coord,
|
||||||
const int64_t num)
|
const int64_t size_max)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||||
return 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') {
|
if (transp != 'N' && transp != 'T') {
|
||||||
return qmckl_failwith( context,
|
return qmckl_failwith( context,
|
||||||
QMCKL_INVALID_ARG_2,
|
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
|
#+begin_src f90 :comments org :tangle (eval fh_func) :noweb yes
|
||||||
interface
|
interface
|
||||||
integer(c_int32_t) function qmckl_set_point(context, &
|
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
|
use, intrinsic :: iso_c_binding
|
||||||
import
|
import
|
||||||
implicit none
|
implicit none
|
||||||
|
@ -358,6 +367,7 @@ interface
|
||||||
character(c_char) , intent(in) , value :: transp
|
character(c_char) , intent(in) , value :: transp
|
||||||
real (c_double ) , intent(in) :: coord(*)
|
real (c_double ) , intent(in) :: coord(*)
|
||||||
integer (c_int64_t) , intent(in) , value :: num
|
integer (c_int64_t) , intent(in) , value :: num
|
||||||
|
integer (c_int64_t) , intent(in) , value :: size_max
|
||||||
end function
|
end function
|
||||||
end interface
|
end interface
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -380,7 +390,7 @@ double coord3[point_num*3];
|
||||||
rc = qmckl_get_point (context, 'N', coord2, (point_num*3));
|
rc = qmckl_get_point (context, 'N', coord2, (point_num*3));
|
||||||
assert(rc == QMCKL_NOT_PROVIDED);
|
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);
|
assert(rc == QMCKL_SUCCESS);
|
||||||
|
|
||||||
int64_t n;
|
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] );
|
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);
|
assert(rc == QMCKL_SUCCESS);
|
||||||
|
|
||||||
rc = qmckl_get_point (context, 'N', coord3, (point_num*3));
|
rc = qmckl_get_point (context, 'N', coord3, (point_num*3));
|
||||||
|
|
|
@ -48,6 +48,10 @@ import_array();
|
||||||
/* Include typemaps generated by the process_header.py script */
|
/* Include typemaps generated by the process_header.py script */
|
||||||
%include "qmckl_include.i"
|
%include "qmckl_include.i"
|
||||||
|
|
||||||
|
/* Handle properly get_point */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* exception.i is a generic (language-independent) module */
|
/* exception.i is a generic (language-independent) module */
|
||||||
%include "exception.i"
|
%include "exception.i"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user