1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 12:23:56 +01:00

Fixed distances

This commit is contained in:
Anthony Scemama 2021-04-17 12:35:52 +02:00
parent 33f33fcdf3
commit 5c285dcdb6
2 changed files with 42 additions and 38 deletions

View File

@ -5,6 +5,9 @@
Functions for the computation of distances between particles.
* Headers :noexport:
#+begin_src elisp :noexport :results none
(org-babel-lob-ingest "../tools/lib.org")
#+end_src
#+begin_src c :comments link :tangle (eval c_test) :noweb yes
#include "qmckl.h"
@ -37,9 +40,9 @@ MunitResult test_<<filename()>>() {
| char | transb | in | Array ~B~ is ~'N'~: Normal, ~'T'~: Transposed |
| int64_t | m | in | Number of points in the first set |
| int64_t | n | in | Number of points in the second set |
| double | A[3][lda] | in | Array containing the $m \times 3$ matrix $A$ |
| double | A[][lda] | in | Array containing the $m \times 3$ matrix $A$ |
| int64_t | lda | in | Leading dimension of array ~A~ |
| double | B[3][ldb] | in | Array containing the $n \times 3$ matrix $B$ |
| double | B[][ldb] | in | Array containing the $n \times 3$ matrix $B$ |
| int64_t | ldb | in | Leading dimension of array ~B~ |
| double | C[n][ldc] | out | Array containing the $m \times n$ matrix $C$ |
| int64_t | ldc | in | Leading dimension of array ~C~ |
@ -74,7 +77,7 @@ MunitResult test_<<filename()>>() {
const int64_t lda,
const double* B,
const int64_t ldb,
double* C,
double* const C,
const int64_t ldc );
#+end_src
@ -214,62 +217,63 @@ end function qmckl_distance_sq_f
** C interface :noexport:
#+CALL: generate_c_interface(table=qmckl_distance_sq_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
#+CALL: generate_c_interface(table=qmckl_distance_sq_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_distance_sq &
#+RESULTS:
#+begin_src f90 :tangle (eval f) :comments org :exports none
integer(c_int32_t) function qmckl_distance_sq &
(context, transa, transb, m, n, A, lda, B, ldb, C, ldc) &
bind(C) result(info)
use, intrinsic :: iso_c_binding
implicit none
integer (c_int64_t) , intent(in) :: context
character , intent(in) :: transa
character , intent(in) :: transb
integer (c_int64_t) , intent(in) :: m
integer (c_int64_t) , intent(in) :: n
real (c_double ) , intent(in) :: A(lda,3)
integer (c_int64_t) , intent(in) :: lda
real (c_double ) , intent(in) :: B(ldb,3)
integer (c_int64_t) , intent(in) :: ldb
integer (c_int64_t) , intent(in) , value :: context
character , intent(in) , value :: transa
character , intent(in) , value :: transb
integer (c_int64_t) , intent(in) , value :: m
integer (c_int64_t) , intent(in) , value :: n
real (c_double ) , intent(in) :: A(lda,*)
integer (c_int64_t) , intent(in) , value :: lda
real (c_double ) , intent(in) :: B(ldb,*)
integer (c_int64_t) , intent(in) , value :: ldb
real (c_double ) , intent(out) :: C(ldc,n)
integer (c_int64_t) , intent(in) :: ldc
integer (c_int64_t) , intent(in) , value :: ldc
integer (c_int32_t), external :: qmckl_distance_sq_f
integer(c_int32_t), external :: qmckl_distance_sq_f
info = qmckl_distance_sq_f &
(context, transa, transb, m, n, A, lda, B, ldb, C, ldc)
end function qmckl_distance_sq
#+end_src
#+end_src
#+CALL: generate_f_interface(table=qmckl_distance_sq_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
#+CALL: generate_f_interface(table=qmckl_distance_sq_args,rettyp=get_value("FRetType"),fname=get_value("Name"))
#+RESULTS:
#+begin_src f90 :tangle (eval fh_func) :comments org :exports none
#+RESULTS:
#+begin_src f90 :tangle (eval fh_func) :comments org :exports none
interface
integer (qmckl_exit_code) function qmckl_distance_sq &
integer(c_int32_t) function qmckl_distance_sq &
(context, transa, transb, m, n, A, lda, B, ldb, C, ldc) &
bind(C)
use, intrinsic :: iso_c_binding
import
implicit none
integer (qmckl_context), intent(in) :: context
character , intent(in) :: transa
character , intent(in) :: transb
integer (c_int64_t) , intent(in) :: m
integer (c_int64_t) , intent(in) :: n
real (c_double ) , intent(in) :: A(lda,3)
integer (c_int64_t) , intent(in) :: lda
real (c_double ) , intent(in) :: B(ldb,3)
integer (c_int64_t) , intent(in) :: ldb
integer (c_int64_t) , intent(in) , value :: context
character , intent(in) , value :: transa
character , intent(in) , value :: transb
integer (c_int64_t) , intent(in) , value :: m
integer (c_int64_t) , intent(in) , value :: n
real (c_double ) , intent(in) :: A(lda,*)
integer (c_int64_t) , intent(in) , value :: lda
real (c_double ) , intent(in) :: B(ldb,*)
integer (c_int64_t) , intent(in) , value :: ldb
real (c_double ) , intent(out) :: C(ldc,n)
integer (c_int64_t) , intent(in) :: ldc
integer (c_int64_t) , intent(in) , value :: ldc
end function qmckl_distance_sq
end interface
#+end_src
#+end_src
*** Test :noexport:
#+begin_src f90 :tangle (eval f_test)

View File

@ -25,9 +25,9 @@
| char | transb | in | Array ~B~ is ~'N'~: Normal, ~'T'~: Transposed |
| int64_t | m | in | Number of points in the first set |
| int64_t | n | in | Number of points in the second set |
| double | A[3][lda] | in | Array containing the $m \times 3$ matrix $A$ |
| double | A[][lda] | in | Array containing the $m \times 3$ matrix $A$ |
| int64_t | lda | in | Leading dimension of array ~A~ |
| double | B[3][ldb] | in | Array containing the $n \times 3$ matrix $B$ |
| double | B[][ldb] | in | Array containing the $n \times 3$ matrix $B$ |
| int64_t | ldb | in | Leading dimension of array ~B~ |
| double | C[n][ldc] | out | Array containing the $m \times n$ matrix $C$ |
| int64_t | ldc | in | Leading dimension of array ~C~ |
@ -92,8 +92,8 @@ def parse_table(table):
elif d["inout"] in ["input/output", "inout"]:
d["inout"] == "inout"
# Find dimensions
dims = d["name"].split('[')
# Find dimensions (replace [] by [*] to get * in Fortran dimensions)
dims = d["name"].replace("[]","[*]").split('[')
d["rank"] = len(dims) - 1
if d["rank"] == 0:
d["dims"] = []