1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-09-27 12:01:02 +02:00

Better org-mode for documentation

This commit is contained in:
Anthony Scemama 2020-11-05 15:34:58 +01:00
parent ccc1b835d1
commit 09a6402783
8 changed files with 635 additions and 646 deletions

View File

@ -93,7 +93,7 @@ rm ${nb}.md
Coding style can be automatically checked with [[https://clang.llvm.org/docs/ClangFormat.html][clang-format]]. Coding style can be automatically checked with [[https://clang.llvm.org/docs/ClangFormat.html][clang-format]].
* Design of the library ** Design of the library
The proposed API should allow the library to: The proposed API should allow the library to:
- deal with memory transfers between CPU and accelerators - deal with memory transfers between CPU and accelerators
@ -102,7 +102,7 @@ rm ${nb}.md
We chose a multi-layered design with low-level and high-level We chose a multi-layered design with low-level and high-level
functions (see below). functions (see below).
** Naming conventions *** Naming conventions
Use =qmckl_= as a prefix for all exported functions and variables. Use =qmckl_= as a prefix for all exported functions and variables.
All exported header files should have a filename with the prefix All exported header files should have a filename with the prefix
@ -114,7 +114,7 @@ rm ${nb}.md
Arrays are in uppercase and scalars are in lowercase. Arrays are in uppercase and scalars are in lowercase.
** Application programming interface *** Application programming interface
The application programming interface (API) is designed to be The application programming interface (API) is designed to be
compatible with the C programming language (not C++), to ensure compatible with the C programming language (not C++), to ensure
@ -134,7 +134,7 @@ rm ${nb}.md
To facilitate the use in other languages than C, we provide some To facilitate the use in other languages than C, we provide some
bindings in other languages in other repositories. bindings in other languages in other repositories.
** Global state *** Global state
Global variables should be avoided in the library, because it is Global variables should be avoided in the library, because it is
possible that one single program needs to use multiple instances of possible that one single program needs to use multiple instances of
@ -155,7 +155,7 @@ rm ${nb}.md
The context and its old versions can be destroyed with The context and its old versions can be destroyed with
=qmckl_context_destroy=. =qmckl_context_destroy=.
** Low-level functions *** Low-level functions
Low-level functions are very simple functions which are leaves of the Low-level functions are very simple functions which are leaves of the
function call tree (they don't call any other QMCkl function). function call tree (they don't call any other QMCkl function).
@ -164,7 +164,7 @@ rm ${nb}.md
not allowed to allocate/deallocate memory, and if they need not allowed to allocate/deallocate memory, and if they need
temporary memory it should be provided in input. temporary memory it should be provided in input.
** High-level functions *** High-level functions
High-level functions are at the top of the function call tree. High-level functions are at the top of the function call tree.
They are able to choose which lower-level function to call They are able to choose which lower-level function to call
@ -179,7 +179,7 @@ rm ${nb}.md
# TODO : We need an identifier for impure functions # TODO : We need an identifier for impure functions
** Numerical precision *** Numerical precision
The number of bits of precision required for a function should be The number of bits of precision required for a function should be
given as an input of low-level computational functions. This input will given as an input of low-level computational functions. This input will
@ -188,7 +188,7 @@ rm ${nb}.md
High-level functions will use the precision specified in the High-level functions will use the precision specified in the
=context= variable. =context= variable.
* Algorithms ** Algorithms
Reducing the scaling of an algorithm usually implies also reducing Reducing the scaling of an algorithm usually implies also reducing
its arithmetic complexity (number of flops per byte). Therefore, its arithmetic complexity (number of flops per byte). Therefore,
@ -197,7 +197,7 @@ rm ${nb}.md
As QMCkl is a general purpose library, multiple algorithms should As QMCkl is a general purpose library, multiple algorithms should
be implemented adapted to different problem sizes. be implemented adapted to different problem sizes.
* Rules for the API ** Rules for the API
- =stdint= should be used for integers (=int32_t=, =int64_t=) - =stdint= should be used for integers (=int32_t=, =int64_t=)
- integers used for counting should always be =int64_t= - integers used for counting should always be =int64_t=
@ -206,13 +206,4 @@ rm ${nb}.md
* Documentation * Documentation
- [[./qmckl.org][Main QMCkl header file]]
- [[./qmckl_memory.org][Memory management]]
- [[./qmckl_context.org][Context]]
- [[./qmckl_distance.org][Distance]]
- [[./qmckl_ao.org][Atomic orbitals]]
* Acknowledgments
[[https://trex-coe.eu/sites/default/files/inline-images/euflag.jpg]]
[[https://trex-coe.eu][TREX: Targeting Real Chemical Accuracy at the Exascale]] project has received funding from the European Unions Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content.

View File

@ -1,11 +1,11 @@
* QMCKL header file ** =qmckl.h= header file
This file produces the =qmckl.h= header file, which is to be included This file produces the =qmckl.h= header file, which is to be included
when qmckl functions are used. when qmckl functions are used.
We also create here the =qmckl_f.f90= which is the Fortran interface file. We also create here the =qmckl_f.f90= which is the Fortran interface file.
** Top of header files :noexport: *** Top of header files :noexport:
#+BEGIN_SRC C :tangle qmckl.h #+BEGIN_SRC C :tangle qmckl.h
#ifndef QMCKL_H #ifndef QMCKL_H
@ -21,9 +21,9 @@ module qmckl
The bottoms of the files are located in the [[qmckl_footer.org]] file. The bottoms of the files are located in the [[qmckl_footer.org]] file.
** Constants *** Constants
*** Success/failure **** Success/failure
These are the codes returned by the functions to indicate success These are the codes returned by the functions to indicate success
or failure. All such functions should have as a return type =qmckl_exit_code=. or failure. All such functions should have as a return type =qmckl_exit_code=.
@ -42,7 +42,7 @@ integer, parameter :: QMCKL_SUCCESS = 0
integer, parameter :: QMCKL_FAILURE = 0 integer, parameter :: QMCKL_FAILURE = 0
#+END_SRC #+END_SRC
*** Precision-related constants **** Precision-related constants
Controlling numerical precision enables optimizations. Here, the Controlling numerical precision enables optimizations. Here, the
default parameters determining the target numerical precision and default parameters determining the target numerical precision and

View File

@ -1,4 +1,4 @@
* Atomic Orbitals ** Atomic Orbitals
This files contains all the routines for the computation of the This files contains all the routines for the computation of the
@ -9,7 +9,7 @@ values, gradients and Laplacian of the atomic basis functions.
- a C test file : =test_qmckl_ao.c= - a C test file : =test_qmckl_ao.c=
- a Fortran test file : =test_qmckl_ao_f.f90= - a Fortran test file : =test_qmckl_ao_f.f90=
** Test :noexport: *** Test :noexport:
#+BEGIN_SRC C :tangle test_qmckl_ao.c #+BEGIN_SRC C :tangle test_qmckl_ao.c
#include <math.h> #include <math.h>
#include "qmckl.h" #include "qmckl.h"
@ -19,7 +19,7 @@ MunitResult test_qmckl_ao() {
context = qmckl_context_create(); context = qmckl_context_create();
#+END_SRC #+END_SRC
** Polynomials *** Polynomials
\[ \[
P_l(\mathbf{r},\mathbf{R}_i) = (x-X_i)^a (y-Y_i)^b (z-Z_i)^c P_l(\mathbf{r},\mathbf{R}_i) = (x-X_i)^a (y-Y_i)^b (z-Z_i)^c
@ -39,14 +39,14 @@ MunitResult test_qmckl_ao() {
&& c(c-1) (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1} && c(c-1) (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1}
\end{eqnarray*} \end{eqnarray*}
*** =qmckl_ao_powers= **** =qmckl_ao_powers=
Computes all the powers of the =n= input data up to the given Computes all the powers of the =n= input data up to the given
maximum value given in input for each of the $n$ points: maximum value given in input for each of the $n$ points:
\[ P_{ij} = X_j^i \] \[ P_{ij} = X_j^i \]
**** Arguments ***** Arguments
| =context= | input | Global state | | =context= | input | Global state |
| =n= | input | Number of values | | =n= | input | Number of values |
@ -55,7 +55,7 @@ MunitResult test_qmckl_ao() {
| =P(LDP,n)= | output | Array containing all the powers of =X= | | =P(LDP,n)= | output | Array containing all the powers of =X= |
| =LDP= | input | Leading dimension of array =P= | | =LDP= | input | Leading dimension of array =P= |
**** Requirements ***** Requirements
- =context= is not 0 - =context= is not 0
- =n= > 0 - =n= > 0
@ -64,7 +64,7 @@ MunitResult test_qmckl_ao() {
- =P= is allocated with at least $n \times \max_i \text{LMAX}_i \times 8$ bytes - =P= is allocated with at least $n \times \max_i \text{LMAX}_i \times 8$ bytes
- =LDP= >= $\max_i$ =LMAX[i]= - =LDP= >= $\max_i$ =LMAX[i]=
**** Header ***** Header
#+BEGIN_SRC C :tangle qmckl.h #+BEGIN_SRC C :tangle qmckl.h
qmckl_exit_code qmckl_ao_powers(const qmckl_context context, qmckl_exit_code qmckl_ao_powers(const qmckl_context context,
const int64_t n, const int64_t n,
@ -72,7 +72,7 @@ qmckl_exit_code qmckl_ao_powers(const qmckl_context context,
const double *P, const int64_t LDP); const double *P, const int64_t LDP);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC f90 :tangle qmckl_ao.f90 #+BEGIN_SRC f90 :tangle qmckl_ao.f90
integer function qmckl_ao_powers_f(context, n, X, LMAX, P, ldp) result(info) integer function qmckl_ao_powers_f(context, n, X, LMAX, P, ldp) result(info)
implicit none implicit none
@ -107,7 +107,7 @@ integer function qmckl_ao_powers_f(context, n, X, LMAX, P, ldp) result(info)
end function qmckl_ao_powers_f end function qmckl_ao_powers_f
#+END_SRC #+END_SRC
**** C interface :noexport: ***** C interface :noexport:
#+BEGIN_SRC f90 :tangle qmckl_ao.f90 #+BEGIN_SRC f90 :tangle qmckl_ao.f90
integer(c_int32_t) function qmckl_ao_powers(context, n, X, LMAX, P, ldp) & integer(c_int32_t) function qmckl_ao_powers(context, n, X, LMAX, P, ldp) &
bind(C) result(info) bind(C) result(info)
@ -139,7 +139,7 @@ end function qmckl_ao_powers
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC f90 :tangle test_qmckl_ao_f.f90 #+BEGIN_SRC f90 :tangle test_qmckl_ao_f.f90
integer(c_int32_t) function test_qmckl_ao_powers(context) bind(C) integer(c_int32_t) function test_qmckl_ao_powers(context) bind(C)
use qmckl use qmckl
@ -191,12 +191,12 @@ munit_assert_int(0, ==, test_qmckl_ao_powers(context));
#+END_SRC #+END_SRC
*** =qmckl_ao_polynomial_vgl= **** =qmckl_ao_polynomial_vgl=
Computes the values, gradients and Laplacians at a given point of Computes the values, gradients and Laplacians at a given point of
all polynomials with an angular momentum up to =lmax=. all polynomials with an angular momentum up to =lmax=.
**** Arguments ***** Arguments
| =context= | input | Global state | | =context= | input | Global state |
| =X(3)= | input | Array containing the coordinates of the points | | =X(3)= | input | Array containing the coordinates of the points |
@ -208,7 +208,7 @@ munit_assert_int(0, ==, test_qmckl_ao_powers(context));
| =VGL(ldv,5)= | output | Value, gradients and Laplacian of the polynomials | | =VGL(ldv,5)= | output | Value, gradients and Laplacian of the polynomials |
| =ldv= | input | Leading dimension of array =VGL= | | =ldv= | input | Leading dimension of array =VGL= |
**** Requirements ***** Requirements
- =context= is not 0 - =context= is not 0
- =n= > 0 - =n= > 0
@ -221,7 +221,7 @@ munit_assert_int(0, ==, test_qmckl_ao_powers(context));
- =VGL= is allocated with at least $n \times 5 \times 8$ bytes - =VGL= is allocated with at least $n \times 5 \times 8$ bytes
- On output, =n= should be equal to (=lmax=+1)(=lmax=+2)(=lmax=+3)/6 - On output, =n= should be equal to (=lmax=+1)(=lmax=+2)(=lmax=+3)/6
**** Header ***** Header
#+BEGIN_SRC C :tangle qmckl.h #+BEGIN_SRC C :tangle qmckl.h
qmckl_exit_code qmckl_ao_polynomial_vgl(const qmckl_context context, qmckl_exit_code qmckl_ao_polynomial_vgl(const qmckl_context context,
const double *X, const double *R, const double *X, const double *R,
@ -230,7 +230,7 @@ qmckl_exit_code qmckl_ao_polynomial_vgl(const qmckl_context context,
const double *VGL, const int64_t ldv); const double *VGL, const int64_t ldv);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC f90 :tangle qmckl_ao.f90 #+BEGIN_SRC f90 :tangle qmckl_ao.f90
integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL, ldv) result(info) integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL, ldv) result(info)
implicit none implicit none
@ -342,7 +342,7 @@ integer function qmckl_ao_polynomial_vgl_f(context, X, R, lmax, n, L, ldl, VGL,
end function qmckl_ao_polynomial_vgl_f end function qmckl_ao_polynomial_vgl_f
#+END_SRC #+END_SRC
**** C interface :noexport: ***** C interface :noexport:
#+BEGIN_SRC f90 :tangle qmckl_ao.f90 #+BEGIN_SRC f90 :tangle qmckl_ao.f90
integer(c_int32_t) function qmckl_ao_polynomial_vgl(context, X, R, lmax, n, L, ldl, VGL, ldv) & integer(c_int32_t) function qmckl_ao_polynomial_vgl(context, X, R, lmax, n, L, ldl, VGL, ldv) &
bind(C) result(info) bind(C) result(info)
@ -378,7 +378,7 @@ end function qmckl_ao_polynomial_vgl
end function qmckl_ao_polynomial_vgl end function qmckl_ao_polynomial_vgl
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC f90 :tangle test_qmckl_ao_f.f90 #+BEGIN_SRC f90 :tangle test_qmckl_ao_f.f90
integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C) integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
use qmckl use qmckl
@ -480,9 +480,9 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
#+END_SRC #+END_SRC
#+END_SRC #+END_SRC
** Gaussian basis functions *** Gaussian basis functions
*** =qmckl_ao_gaussians_vgl= **** =qmckl_ao_gaussians_vgl=
Computes the values, gradients and Laplacians at a given point of Computes the values, gradients and Laplacians at a given point of
=n= Gaussian functions centered at the same point: =n= Gaussian functions centered at the same point:
@ -493,7 +493,7 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
\[ \nabla_z v_i = -2 a_i (X_z - R_z) v_i \] \[ \nabla_z v_i = -2 a_i (X_z - R_z) v_i \]
\[ \Delta v_i = a_i (4 |X-R|^2 a_i - 6) v_i \] \[ \Delta v_i = a_i (4 |X-R|^2 a_i - 6) v_i \]
**** Arguments ***** Arguments
| =context= | input | Global state | | =context= | input | Global state |
| =X(3)= | input | Array containing the coordinates of the points | | =X(3)= | input | Array containing the coordinates of the points |
@ -503,7 +503,7 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
| =VGL(ldv,5)= | output | Value, gradients and Laplacian of the Gaussians | | =VGL(ldv,5)= | output | Value, gradients and Laplacian of the Gaussians |
| =ldv= | input | Leading dimension of array =VGL= | | =ldv= | input | Leading dimension of array =VGL= |
**** Requirements ***** Requirements
- =context= is not 0 - =context= is not 0
- =n= > 0 - =n= > 0
@ -514,7 +514,7 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
- =A= is allocated with at least $n \times 8$ bytes - =A= is allocated with at least $n \times 8$ bytes
- =VGL= is allocated with at least $n \times 5 \times 8$ bytes - =VGL= is allocated with at least $n \times 5 \times 8$ bytes
**** Header ***** Header
#+BEGIN_SRC C :tangle qmckl.h #+BEGIN_SRC C :tangle qmckl.h
qmckl_exit_code qmckl_ao_gaussians_vgl(const qmckl_context context, qmckl_exit_code qmckl_ao_gaussians_vgl(const qmckl_context context,
const double *X, const double *R, const double *X, const double *R,
@ -522,7 +522,7 @@ qmckl_exit_code qmckl_ao_gaussians_vgl(const qmckl_context context,
const double *VGL, const int64_t ldv); const double *VGL, const int64_t ldv);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC f90 :tangle qmckl_ao.f90 #+BEGIN_SRC f90 :tangle qmckl_ao.f90
integer function qmckl_ao_gaussians_vgl_f(context, X, R, n, A, VGL, ldv) result(info) integer function qmckl_ao_gaussians_vgl_f(context, X, R, n, A, VGL, ldv) result(info)
implicit none implicit none
@ -585,7 +585,7 @@ integer function qmckl_ao_gaussians_vgl_f(context, X, R, n, A, VGL, ldv) result(
end function qmckl_ao_gaussians_vgl_f end function qmckl_ao_gaussians_vgl_f
#+END_SRC #+END_SRC
**** C interface :noexport: ***** C interface :noexport:
#+BEGIN_SRC f90 :tangle qmckl_ao.f90 #+BEGIN_SRC f90 :tangle qmckl_ao.f90
integer(c_int32_t) function qmckl_ao_gaussians_vgl(context, X, R, n, A, VGL, ldv) & integer(c_int32_t) function qmckl_ao_gaussians_vgl(context, X, R, n, A, VGL, ldv) &
bind(C) result(info) bind(C) result(info)
@ -616,7 +616,7 @@ end function qmckl_ao_gaussians_vgl
end function qmckl_ao_gaussians_vgl end function qmckl_ao_gaussians_vgl
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC f90 :tangle test_qmckl_ao_f.f90 #+BEGIN_SRC f90 :tangle test_qmckl_ao_f.f90
integer(c_int32_t) function test_qmckl_ao_gaussians_vgl(context) bind(C) integer(c_int32_t) function test_qmckl_ao_gaussians_vgl(context) bind(C)
use qmckl use qmckl
@ -691,11 +691,11 @@ munit_assert_int(0, ==, test_qmckl_ao_gaussians_vgl(context));
#+END_SRC #+END_SRC
** TODO Slater basis functions *** TODO Slater basis functions
** End of files :noexport: *** End of files :noexport:
**** Test ***** Test
#+BEGIN_SRC C :tangle test_qmckl_ao.c #+BEGIN_SRC C :tangle test_qmckl_ao.c
if (qmckl_context_destroy(context) != QMCKL_SUCCESS) if (qmckl_context_destroy(context) != QMCKL_SUCCESS)
return QMCKL_FAILURE; return QMCKL_FAILURE;

View File

@ -1,4 +1,4 @@
* Context ** Context
This file is written in C because it is more natural to express the context in This file is written in C because it is more natural to express the context in
C than in Fortran. C than in Fortran.
@ -7,7 +7,7 @@
- a source file : =qmckl_context.c= - a source file : =qmckl_context.c=
- a test file : =test_qmckl_context.c= - a test file : =test_qmckl_context.c=
** Headers :noexport: *** Headers :noexport:
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
#include "qmckl.h" #include "qmckl.h"
#+END_SRC #+END_SRC
@ -18,7 +18,7 @@
MunitResult test_qmckl_context() { MunitResult test_qmckl_context() {
#+END_SRC #+END_SRC
** Context *** Context
The context variable is a handle for the state of the library, and The context variable is a handle for the state of the library, and
is stored in the following data structure, which can't be seen is stored in the following data structure, which can't be seen
@ -30,7 +30,7 @@ MunitResult test_qmckl_context() {
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
#+END_SRC #+END_SRC
**** Source ***** Source
The tag is used internally to check if the memory domain pointed by The tag is used internally to check if the memory domain pointed by
a pointer is a valid context. a pointer is a valid context.
@ -47,14 +47,14 @@ typedef struct qmckl_context_struct {
#define INVALID_TAG 0xDEADBEEF #define INVALID_TAG 0xDEADBEEF
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC C :tangle test_qmckl_context.c #+BEGIN_SRC C :tangle test_qmckl_context.c
qmckl_context context; qmckl_context context;
qmckl_context new_context; qmckl_context new_context;
#+END_SRC #+END_SRC
*** =qmckl_context_check= **** =qmckl_context_check=
Checks if the domain pointed by the pointer is a valid context. Checks if the domain pointed by the pointer is a valid context.
Returns the input =qmckl_context= if the context is valid, 0 otherwise. Returns the input =qmckl_context= if the context is valid, 0 otherwise.
@ -63,7 +63,7 @@ qmckl_context new_context;
qmckl_context qmckl_context_check(const qmckl_context context) ; qmckl_context qmckl_context_check(const qmckl_context context) ;
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_check(const qmckl_context context) { qmckl_context qmckl_context_check(const qmckl_context context) {
@ -77,7 +77,7 @@ qmckl_context qmckl_context_check(const qmckl_context context) {
} }
#+END_SRC #+END_SRC
*** =qmckl_context_create= **** =qmckl_context_create=
To create a new context, use =qmckl_context_create()=. To create a new context, use =qmckl_context_create()=.
- On success, returns a pointer to a context using the =qmckl_context= type - On success, returns a pointer to a context using the =qmckl_context= type
@ -87,7 +87,7 @@ qmckl_context qmckl_context_check(const qmckl_context context) {
qmckl_context qmckl_context_create(); qmckl_context qmckl_context_create();
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_create() { qmckl_context qmckl_context_create() {
@ -106,7 +106,7 @@ qmckl_context qmckl_context_create() {
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int64_t) function qmckl_context_create() bind(C) integer (c_int64_t) function qmckl_context_create() bind(C)
@ -115,14 +115,14 @@ qmckl_context qmckl_context_create() {
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c #+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
context = qmckl_context_create(); context = qmckl_context_create();
munit_assert_int64( context, !=, (qmckl_context) 0); munit_assert_int64( context, !=, (qmckl_context) 0);
munit_assert_int64( qmckl_context_check(context), ==, context); munit_assert_int64( qmckl_context_check(context), ==, context);
#+END_SRC #+END_SRC
*** =qmckl_context_copy= **** =qmckl_context_copy=
This function makes a shallow copy of the current context. This function makes a shallow copy of the current context.
- Copying the 0-valued context returns 0 - Copying the 0-valued context returns 0
@ -134,7 +134,7 @@ munit_assert_int64( qmckl_context_check(context), ==, context);
qmckl_context qmckl_context_copy(const qmckl_context context); qmckl_context qmckl_context_copy(const qmckl_context context);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_copy(const qmckl_context context) { qmckl_context qmckl_context_copy(const qmckl_context context) {
@ -162,7 +162,7 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int64_t) function qmckl_context_copy(context) bind(C) integer (c_int64_t) function qmckl_context_copy(context) bind(C)
@ -172,7 +172,7 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c #+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
new_context = qmckl_context_copy(context); new_context = qmckl_context_copy(context);
munit_assert_int64(new_context, !=, (qmckl_context) 0); munit_assert_int64(new_context, !=, (qmckl_context) 0);
@ -180,7 +180,7 @@ munit_assert_int64(new_context, !=, context);
munit_assert_int64(qmckl_context_check(new_context), ==, new_context); munit_assert_int64(qmckl_context_check(new_context), ==, new_context);
#+END_SRC #+END_SRC
*** =qmckl_context_previous= **** =qmckl_context_previous=
Returns the previous context Returns the previous context
- On success, returns the ancestor of the current context - On success, returns the ancestor of the current context
@ -191,7 +191,7 @@ munit_assert_int64(qmckl_context_check(new_context), ==, new_context);
qmckl_context qmckl_context_previous(const qmckl_context context); qmckl_context qmckl_context_previous(const qmckl_context context);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_previous(const qmckl_context context) { qmckl_context qmckl_context_previous(const qmckl_context context) {
@ -205,7 +205,7 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int64_t) function qmckl_context_previous(context) bind(C) integer (c_int64_t) function qmckl_context_previous(context) bind(C)
@ -215,7 +215,7 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c #+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
munit_assert_int64(qmckl_context_previous(new_context), !=, (qmckl_context) 0); munit_assert_int64(qmckl_context_previous(new_context), !=, (qmckl_context) 0);
munit_assert_int64(qmckl_context_previous(new_context), ==, context); munit_assert_int64(qmckl_context_previous(new_context), ==, context);
@ -223,7 +223,7 @@ munit_assert_int64(qmckl_context_previous(context), ==, (qmckl_context) 0);
munit_assert_int64(qmckl_context_previous((qmckl_context) 0), ==, (qmckl_context) 0); munit_assert_int64(qmckl_context_previous((qmckl_context) 0), ==, (qmckl_context) 0);
#+END_SRC #+END_SRC
*** =qmckl_context_destroy= **** =qmckl_context_destroy=
Destroys the current context, leaving the ancestors untouched. Destroys the current context, leaving the ancestors untouched.
- Succeeds if the current context is properly destroyed - Succeeds if the current context is properly destroyed
@ -235,7 +235,7 @@ munit_assert_int64(qmckl_context_previous((qmckl_context) 0), ==, (qmckl_context
qmckl_exit_code qmckl_context_destroy(qmckl_context context); qmckl_exit_code qmckl_context_destroy(qmckl_context context);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_exit_code qmckl_context_destroy(const qmckl_context context) { qmckl_exit_code qmckl_context_destroy(const qmckl_context context) {
@ -251,7 +251,7 @@ qmckl_exit_code qmckl_context_destroy(const qmckl_context context) {
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_destroy(context) bind(C) integer (c_int32_t) function qmckl_context_destroy(context) bind(C)
@ -261,7 +261,7 @@ qmckl_exit_code qmckl_context_destroy(const qmckl_context context) {
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC C :tangle test_qmckl_context.c #+BEGIN_SRC C :tangle test_qmckl_context.c
munit_assert_int64(qmckl_context_check(new_context), ==, new_context); munit_assert_int64(qmckl_context_check(new_context), ==, new_context);
munit_assert_int64(new_context, !=, (qmckl_context) 0); munit_assert_int64(new_context, !=, (qmckl_context) 0);
@ -272,7 +272,7 @@ munit_assert_int64(qmckl_context_destroy((qmckl_context) 0), ==, QMCKL_FAILURE);
#+END_SRC #+END_SRC
** Precision *** Precision
The following functions set and get the expected required precision The following functions set and get the expected required precision
and range. =precision= should be an integer between 2 and 53, and and range. =precision= should be an integer between 2 and 53, and
@ -282,13 +282,13 @@ munit_assert_int64(qmckl_context_destroy((qmckl_context) 0), ==, QMCKL_FAILURE);
The getter functions return the value, as a 32-bit integer. The getter functions return the value, as a 32-bit integer.
The update functions return =QMCKL_SUCCESS= or =QMCKL_FAILURE=. The update functions return =QMCKL_SUCCESS= or =QMCKL_FAILURE=.
*** =qmckl_context_update_precision= **** =qmckl_context_update_precision=
Modifies the parameter for the numerical precision in a given context. Modifies the parameter for the numerical precision in a given context.
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, const int precision); qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, const int precision);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, const int precision) { qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, const int precision) {
@ -303,7 +303,7 @@ qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, cons
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_update_precision(context, precision) bind(C) integer (c_int32_t) function qmckl_context_update_precision(context, precision) bind(C)
@ -314,14 +314,14 @@ qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, cons
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
*** =qmckl_context_update_range= **** =qmckl_context_update_range=
Modifies the parameter for the numerical range in a given context. Modifies the parameter for the numerical range in a given context.
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const int range); qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const int range);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const int range) { qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const int range) {
@ -336,7 +336,7 @@ qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const in
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_update_range(context, range) bind(C) integer (c_int32_t) function qmckl_context_update_range(context, range) bind(C)
@ -347,14 +347,14 @@ qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const in
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
*** =qmckl_context_set_precision= **** =qmckl_context_set_precision=
Returns a copy of the context with a different precision parameter. Returns a copy of the context with a different precision parameter.
#+BEGIN_SRC C :comments or :tangle qmckl.h #+BEGIN_SRC C :comments or :tangle qmckl.h
qmckl_context qmckl_context_set_precision(const qmckl_context context, const int precision); qmckl_context qmckl_context_set_precision(const qmckl_context context, const int precision);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_set_precision(const qmckl_context context, const int precision) { qmckl_context qmckl_context_set_precision(const qmckl_context context, const int precision) {
qmckl_context new_context = qmckl_context_copy(context); qmckl_context new_context = qmckl_context_copy(context);
@ -366,7 +366,7 @@ qmckl_context qmckl_context_set_precision(const qmckl_context context, const int
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_set_precision(context, precision) bind(C) integer (c_int32_t) function qmckl_context_set_precision(context, precision) bind(C)
@ -377,14 +377,14 @@ qmckl_context qmckl_context_set_precision(const qmckl_context context, const int
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
*** =qmckl_context_set_range= **** =qmckl_context_set_range=
Returns a copy of the context with a different precision parameter. Returns a copy of the context with a different precision parameter.
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
qmckl_context qmckl_context_set_range(const qmckl_context context, const int range); qmckl_context qmckl_context_set_range(const qmckl_context context, const int range);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_set_range(const qmckl_context context, const int range) { qmckl_context qmckl_context_set_range(const qmckl_context context, const int range) {
qmckl_context new_context = qmckl_context_copy(context); qmckl_context new_context = qmckl_context_copy(context);
@ -396,7 +396,7 @@ qmckl_context qmckl_context_set_range(const qmckl_context context, const int ran
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_set_range(context, range) bind(C) integer (c_int32_t) function qmckl_context_set_range(context, range) bind(C)
@ -407,15 +407,15 @@ qmckl_context qmckl_context_set_range(const qmckl_context context, const int ran
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
*** =qmckl_context_get_precision= **** =qmckl_context_get_precision=
Returns the value of the numerical precision in the context Returns the value of the numerical precision in the context
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
int32_t qmckl_context_get_precision(const qmckl_context context); int32_t qmckl_context_get_precision(const qmckl_context context);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
int qmckl_context_get_precision(const qmckl_context context) { int qmckl_context_get_precision(const qmckl_context context) {
const qmckl_context_struct* ctx = (qmckl_context_struct*) context; const qmckl_context_struct* ctx = (qmckl_context_struct*) context;
@ -423,7 +423,7 @@ int qmckl_context_get_precision(const qmckl_context context) {
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_get_precision(context) bind(C) integer (c_int32_t) function qmckl_context_get_precision(context) bind(C)
@ -433,14 +433,14 @@ int qmckl_context_get_precision(const qmckl_context context) {
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
*** =qmckl_context_get_range= **** =qmckl_context_get_range=
Returns the value of the numerical range in the context Returns the value of the numerical range in the context
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
int32_t qmckl_context_get_range(const qmckl_context context); int32_t qmckl_context_get_range(const qmckl_context context);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
int qmckl_context_get_range(const qmckl_context context) { int qmckl_context_get_range(const qmckl_context context) {
const qmckl_context_struct* ctx = (qmckl_context_struct*) context; const qmckl_context_struct* ctx = (qmckl_context_struct*) context;
@ -448,7 +448,7 @@ int qmckl_context_get_range(const qmckl_context context) {
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
integer (c_int32_t) function qmckl_context_get_range(context) bind(C) integer (c_int32_t) function qmckl_context_get_range(context) bind(C)
@ -458,15 +458,15 @@ int qmckl_context_get_range(const qmckl_context context) {
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
*** =qmckl_context_get_epsilon= **** =qmckl_context_get_epsilon=
Returns $\epsilon = 2 / \log_{10} 2^{n-1}$ where =n= is the precision Returns $\epsilon = 2 / \log_{10} 2^{n-1}$ where =n= is the precision
#+BEGIN_SRC C :comments org :tangle qmckl.h #+BEGIN_SRC C :comments org :tangle qmckl.h
double qmckl_context_get_epsilon(const qmckl_context context); double qmckl_context_get_epsilon(const qmckl_context context);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC C :tangle qmckl_context.c #+BEGIN_SRC C :tangle qmckl_context.c
double qmckl_context_get_epsilon(const qmckl_context context) { double qmckl_context_get_epsilon(const qmckl_context context) {
const qmckl_context_struct* ctx = (qmckl_context_struct*) context; const qmckl_context_struct* ctx = (qmckl_context_struct*) context;
@ -474,7 +474,7 @@ double qmckl_context_get_epsilon(const qmckl_context context) {
} }
#+END_SRC #+END_SRC
**** Fortran interface ***** Fortran interface
#+BEGIN_SRC f90 :tangle qmckl_f.f90 #+BEGIN_SRC f90 :tangle qmckl_f.f90
interface interface
real (c_double) function qmckl_context_get_epsilon(context) bind(C) real (c_double) function qmckl_context_get_epsilon(context) bind(C)
@ -484,17 +484,17 @@ double qmckl_context_get_epsilon(const qmckl_context context) {
end interface end interface
#+END_SRC #+END_SRC
**** TODO Tests :noexport: ***** TODO Tests :noexport:
** Info about the molecular system *** Info about the molecular system
*** TODO =qmckl_context_set_nucl_coord= **** TODO =qmckl_context_set_nucl_coord=
*** TODO =qmckl_context_set_nucl_charge= **** TODO =qmckl_context_set_nucl_charge=
*** TODO =qmckl_context_set_elec_num= **** TODO =qmckl_context_set_elec_num=
** End of files :noexport: *** End of files :noexport:
**** Test ***** Test
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c #+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
return MUNIT_OK; return MUNIT_OK;
} }

View File

@ -1,4 +1,4 @@
* Computation of distances ** Computation of distances
Function for the computation of distances between particles. Function for the computation of distances between particles.
@ -7,7 +7,7 @@ Function for the computation of distances between particles.
- a C test file : =test_qmckl_distance.c= - a C test file : =test_qmckl_distance.c=
- a Fortran test file : =test_qmckl_distance_f.f90= - a Fortran test file : =test_qmckl_distance_f.f90=
*** Headers :noexport: **** Headers :noexport:
#+BEGIN_SRC C :comments link :tangle test_qmckl_distance.c #+BEGIN_SRC C :comments link :tangle test_qmckl_distance.c
#include <math.h> #include <math.h>
#include "qmckl.h" #include "qmckl.h"
@ -19,9 +19,9 @@ MunitResult test_qmckl_distance() {
#+END_SRC #+END_SRC
** Squared distance *** Squared distance
*** =qmckl_distance_sq= **** =qmckl_distance_sq=
Computes the matrix of the squared distances between all pairs of Computes the matrix of the squared distances between all pairs of
points in two sets, one point within each set: points in two sets, one point within each set:
@ -29,7 +29,7 @@ MunitResult test_qmckl_distance() {
C_{ij} = \sum_{k=1}^3 (A_{k,i}-B_{k,j})^2 C_{ij} = \sum_{k=1}^3 (A_{k,i}-B_{k,j})^2
\] \]
**** Arguments ***** Arguments
| =context= | input | Global state | | =context= | input | Global state |
| =transa= | input | Array =A= is =N=: Normal, =T=: Transposed | | =transa= | input | Array =A= is =N=: Normal, =T=: Transposed |
@ -43,7 +43,7 @@ MunitResult test_qmckl_distance() {
| =C(ldc,n)= | output | Array containing the $m \times n$ matrix $C$ | | =C(ldc,n)= | output | Array containing the $m \times n$ matrix $C$ |
| =ldc= | input | Leading dimension of array =C= | | =ldc= | input | Leading dimension of array =C= |
**** Requirements ***** Requirements
- =context= is not 0 - =context= is not 0
- =m= > 0 - =m= > 0
@ -57,7 +57,7 @@ MunitResult test_qmckl_distance() {
- =B= is allocated with at least $3 \times n \times 8$ bytes - =B= is allocated with at least $3 \times n \times 8$ bytes
- =C= is allocated with at least $m \times n \times 8$ bytes - =C= is allocated with at least $m \times n \times 8$ bytes
**** Performance ***** Performance
This function might be more efficient when =A= and =B= are This function might be more efficient when =A= and =B= are
transposed. transposed.
@ -71,7 +71,7 @@ qmckl_exit_code qmckl_distance_sq(const qmckl_context context,
const double *C, const int64_t ldc); const double *C, const int64_t ldc);
#+END_SRC #+END_SRC
**** Source ***** Source
#+BEGIN_SRC f90 :tangle qmckl_distance.f90 #+BEGIN_SRC f90 :tangle qmckl_distance.f90
integer function qmckl_distance_sq_f(context, transa, transb, m, n, A, LDA, B, LDB, C, LDC) result(info) integer function qmckl_distance_sq_f(context, transa, transb, m, n, A, LDA, B, LDB, C, LDC) result(info)
implicit none implicit none
@ -199,7 +199,7 @@ integer function qmckl_distance_sq_f(context, transa, transb, m, n, A, LDA, B, L
end function qmckl_distance_sq_f end function qmckl_distance_sq_f
#+END_SRC #+END_SRC
**** C interface :noexport: ***** C interface :noexport:
#+BEGIN_SRC f90 :tangle qmckl_distance.f90 #+BEGIN_SRC f90 :tangle qmckl_distance.f90
integer(c_int32_t) function qmckl_distance_sq(context, transa, transb, m, n, A, LDA, B, LDB, C, LDC) & integer(c_int32_t) function qmckl_distance_sq(context, transa, transb, m, n, A, LDA, B, LDB, C, LDC) &
bind(C) result(info) bind(C) result(info)
@ -239,7 +239,7 @@ end function qmckl_distance_sq
end interface end interface
#+END_SRC #+END_SRC
**** Test :noexport: ***** Test :noexport:
#+BEGIN_SRC f90 :tangle test_qmckl_distance_f.f90 #+BEGIN_SRC f90 :tangle test_qmckl_distance_f.f90
integer(c_int32_t) function test_qmckl_distance_sq(context) bind(C) integer(c_int32_t) function test_qmckl_distance_sq(context) bind(C)
use qmckl use qmckl
@ -342,7 +342,7 @@ end function test_qmckl_distance_sq
int test_qmckl_distance_sq(qmckl_context context); int test_qmckl_distance_sq(qmckl_context context);
munit_assert_int(0, ==, test_qmckl_distance_sq(context)); munit_assert_int(0, ==, test_qmckl_distance_sq(context));
#+END_SRC #+END_SRC
** End of files :noexport: *** End of files :noexport:
#+BEGIN_SRC C :comments link :tangle test_qmckl_distance.c #+BEGIN_SRC C :comments link :tangle test_qmckl_distance.c
if (qmckl_context_destroy(context) != QMCKL_SUCCESS) if (qmckl_context_destroy(context) != QMCKL_SUCCESS)

View File

@ -1,3 +1,8 @@
* Acknowledgments
[[https://trex-coe.eu/sites/default/files/inline-images/euflag.jpg]]
[[https://trex-coe.eu][TREX: Targeting Real Chemical Accuracy at the Exascale]] project has received funding from the European Unions Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content.
* End of header files :noexport: * End of header files :noexport:
#+BEGIN_SRC C :tangle qmckl.h #+BEGIN_SRC C :tangle qmckl.h

View File

@ -1,4 +1,4 @@
* Memory management ** Memory management
We override the allocation functions to enable the possibility of We override the allocation functions to enable the possibility of
optimized libraries to fine-tune the memory allocation. optimized libraries to fine-tune the memory allocation.
@ -7,7 +7,7 @@ optimized libraries to fine-tune the memory allocation.
- a source file : =qmckl_memory.c= - a source file : =qmckl_memory.c=
- a test file : =test_qmckl_memory.c= - a test file : =test_qmckl_memory.c=
** Headers :noexport: *** Headers :noexport:
#+BEGIN_SRC C :tangle qmckl_memory.c #+BEGIN_SRC C :tangle qmckl_memory.c
#include "qmckl.h" #include "qmckl.h"
#+END_SRC #+END_SRC
@ -18,7 +18,7 @@ optimized libraries to fine-tune the memory allocation.
MunitResult test_qmckl_memory() { MunitResult test_qmckl_memory() {
#+END_SRC #+END_SRC
** =qmckl_malloc= *** =qmckl_malloc=
Memory allocation function, letting the library choose how the Memory allocation function, letting the library choose how the
memory will be allocated, and a pointer is returned to the user. memory will be allocated, and a pointer is returned to the user.
@ -37,7 +37,7 @@ void* qmckl_malloc(const qmckl_context ctx, const size_t size);
end interface end interface
#+END_SRC #+END_SRC
*** Source **** Source
#+BEGIN_SRC C :tangle qmckl_memory.c #+BEGIN_SRC C :tangle qmckl_memory.c
void* qmckl_malloc(const qmckl_context ctx, const size_t size) { void* qmckl_malloc(const qmckl_context ctx, const size_t size) {
if (ctx == (qmckl_context) 0) { if (ctx == (qmckl_context) 0) {
@ -49,7 +49,7 @@ void* qmckl_malloc(const qmckl_context ctx, const size_t size) {
#+END_SRC #+END_SRC
*** Test :noexport: **** Test :noexport:
#+BEGIN_SRC C :tangle test_qmckl_memory.c #+BEGIN_SRC C :tangle test_qmckl_memory.c
int *a; int *a;
a = (int*) qmckl_malloc( (qmckl_context) 1, 3*sizeof(int)); a = (int*) qmckl_malloc( (qmckl_context) 1, 3*sizeof(int));
@ -61,7 +61,7 @@ munit_assert_int(a[1], ==, 2);
munit_assert_int(a[2], ==, 3); munit_assert_int(a[2], ==, 3);
#+END_SRC #+END_SRC
** =qmckl_free= *** =qmckl_free=
#+BEGIN_SRC C :tangle qmckl.h #+BEGIN_SRC C :tangle qmckl.h
void qmckl_free(void *ptr); void qmckl_free(void *ptr);
@ -75,21 +75,21 @@ void qmckl_free(void *ptr);
end subroutine qmckl_free end subroutine qmckl_free
end interface end interface
#+END_SRC #+END_SRC
*** Source **** Source
#+BEGIN_SRC C :tangle qmckl_memory.c #+BEGIN_SRC C :tangle qmckl_memory.c
void qmckl_free(void *ptr) { void qmckl_free(void *ptr) {
free(ptr); free(ptr);
} }
#+END_SRC #+END_SRC
*** Test :noexport: **** Test :noexport:
#+BEGIN_SRC C :tangle test_qmckl_memory.c #+BEGIN_SRC C :tangle test_qmckl_memory.c
qmckl_free(a); qmckl_free(a);
#+END_SRC #+END_SRC
** End of files :noexport: *** End of files :noexport:
*** Test **** Test
#+BEGIN_SRC C :comments org :tangle test_qmckl_memory.c #+BEGIN_SRC C :comments org :tangle test_qmckl_memory.c
return MUNIT_OK; return MUNIT_OK;
} }

View File

@ -1,11 +1,4 @@
#+TITLE: QMCkl test * QMCkl test :noexport:
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
This file is the main program of the unit tests. The tests rely on the This file is the main program of the unit tests. The tests rely on the
$\mu$unit framework, which is provided as a git submodule. $\mu$unit framework, which is provided as a git submodule.