mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-08-17 02:41:43 +02:00
Simplify org-mode
This commit is contained in:
parent
e774a725b9
commit
ccc1b835d1
13
src/Makefile
13
src/Makefile
@ -5,7 +5,7 @@ FC=gfortran -g
|
|||||||
FFLAGS=-fPIC -fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant -Wuninitialized -fbacktrace -ffpe-trap=zero,overflow,underflow -finit-real=nan
|
FFLAGS=-fPIC -fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant -Wuninitialized -fbacktrace -ffpe-trap=zero,overflow,underflow -finit-real=nan
|
||||||
|
|
||||||
LIBS=-lgfortran -lm
|
LIBS=-lgfortran -lm
|
||||||
#
|
|
||||||
#CC=icc -xHost
|
#CC=icc -xHost
|
||||||
#CFLAGS=-fPIC -g -O2
|
#CFLAGS=-fPIC -g -O2
|
||||||
#
|
#
|
||||||
@ -30,15 +30,18 @@ libqmckl.so: Makefile.generated
|
|||||||
test: Makefile.generated
|
test: Makefile.generated
|
||||||
$(MAKE) -f Makefile.generated test
|
$(MAKE) -f Makefile.generated test
|
||||||
|
|
||||||
$(MERGED_ORG): $(ORG_SOURCE_FILES)
|
|
||||||
./merge_org.sh
|
|
||||||
|
|
||||||
doc:$(MERGED_ORG)
|
doc: $(ORG_SOURCE_FILES)
|
||||||
|
./merge_org.sh
|
||||||
./create_doc.sh $(MERGED_ORG)
|
./create_doc.sh $(MERGED_ORG)
|
||||||
|
rm $(MERGED_ORG)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f qmckl.h test_qmckl_* test_qmckl.c test_qmckl qmckl_*.f90 qmckl_*.c qmckl_*.o qmckl_*.h Makefile.generated libqmckl.so *.html *.fh *.mod
|
rm -f qmckl.h test_qmckl_* test_qmckl.c test_qmckl qmckl_*.f90 qmckl_*.c qmckl_*.o qmckl_*.h Makefile.generated libqmckl.so *.html *.fh *.mod
|
||||||
|
|
||||||
Makefile.generated: $(MERGED_ORG) Makefile create_makefile.sh
|
Makefile.generated: Makefile create_makefile.sh $(ORG_SOURCE_FILES)
|
||||||
|
./merge_org.sh
|
||||||
./create_makefile.sh $(MERGED_ORG)
|
./create_makefile.sh $(MERGED_ORG)
|
||||||
|
rm $(MERGED_ORG)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ for i in README.org \
|
|||||||
qmckl_context.org \
|
qmckl_context.org \
|
||||||
qmckl_distance.org \
|
qmckl_distance.org \
|
||||||
qmckl_ao.org \
|
qmckl_ao.org \
|
||||||
|
qmckl_footer.org \
|
||||||
test_qmckl.org
|
test_qmckl.org
|
||||||
do
|
do
|
||||||
cat $i >> merged_qmckl.org
|
cat $i >> merged_qmckl.org
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
# -*- mode: org -*-
|
* QMCKL header file
|
||||||
# vim: syntax=c
|
|
||||||
#+TITLE: QMCkl C header
|
|
||||||
|
|
||||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
|
This file produces the =qmckl.h= header file, which is to be included
|
||||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
|
when qmckl functions are used.
|
||||||
#+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 produces the =qmckl.h= header file, which is included in all
|
We also create here the =qmckl_f.f90= which is the Fortran interface file.
|
||||||
other C header files. It is the main entry point to the library.
|
|
||||||
|
|
||||||
We also create the =qmckl_f.f90= which is the Fortran equivalent.
|
** Top of header files :noexport:
|
||||||
|
|
||||||
#+BEGIN_SRC C :tangle qmckl.h
|
#+BEGIN_SRC C :tangle qmckl.h
|
||||||
#ifndef QMCKL_H
|
#ifndef QMCKL_H
|
||||||
@ -26,14 +19,16 @@ module qmckl
|
|||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Constants
|
The bottoms of the files are located in the [[qmckl_footer.org]] file.
|
||||||
|
|
||||||
** Success/failure
|
** Constants
|
||||||
|
|
||||||
|
*** 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=.
|
||||||
|
|
||||||
#+BEGIN_SRC C :tangle qmckl.h
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#define QMCKL_SUCCESS 0
|
#define QMCKL_SUCCESS 0
|
||||||
#define QMCKL_FAILURE 1
|
#define QMCKL_FAILURE 1
|
||||||
|
|
||||||
@ -42,63 +37,27 @@ typedef int64_t qmckl_context ;
|
|||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
#+BEGIN_SRC f90 :comments org :tangle qmckl_f.f90
|
||||||
integer, parameter :: QMCKL_SUCCESS = 0
|
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
|
||||||
range are defined.
|
range are defined.
|
||||||
|
|
||||||
#+BEGIN_SRC C :tangle qmckl.h
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#define QMCKL_DEFAULT_PRECISION 53
|
#define QMCKL_DEFAULT_PRECISION 53
|
||||||
#define QMCKL_DEFAULT_RANGE 11
|
#define QMCKL_DEFAULT_RANGE 11
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
#+BEGIN_SRC f90 :comments org :tangle qmckl_f.f90
|
||||||
integer, parameter :: QMCKL_DEFAULT_PRECISION = 53
|
integer, parameter :: QMCKL_DEFAULT_PRECISION = 53
|
||||||
integer, parameter :: QMCKL_DEFAULT_RANGE = 11
|
integer, parameter :: QMCKL_DEFAULT_RANGE = 11
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Header files
|
|
||||||
|
|
||||||
All the functions expoed in the API are defined in the following
|
# -*- mode: org -*-
|
||||||
header files.
|
# vim: syntax=c
|
||||||
|
|
||||||
#+BEGIN_SRC C :tangle qmckl.h
|
|
||||||
|
|
||||||
#include "qmckl_memory.h"
|
|
||||||
#include "qmckl_context.h"
|
|
||||||
|
|
||||||
#include "qmckl_distance.h"
|
|
||||||
#include "qmckl_ao.h"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
|
||||||
! include 'qmckl_memory.fh'
|
|
||||||
include 'qmckl_context.fh'
|
|
||||||
include 'qmckl_distance.fh'
|
|
||||||
include 'qmckl_ao.fh'
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* End of header
|
|
||||||
|
|
||||||
#+BEGIN_SRC C :tangle qmckl.h
|
|
||||||
#endif
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
|
||||||
end module qmckl
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
|
|
||||||
* Include all other org files here :noexport:
|
|
||||||
|
|
||||||
#+INCLUDE: qmckl_memory.org
|
|
||||||
#+INCLUDE: qmckl_context.org
|
|
||||||
#+INCLUDE: qmckl_distance.org
|
|
||||||
#+INCLUDE: qmckl_ao.org
|
|
||||||
|
127
src/qmckl_ao.org
127
src/qmckl_ao.org
@ -1,33 +1,16 @@
|
|||||||
# -*- mode: org -*-
|
* Atomic Orbitals
|
||||||
# vim: syntax=c
|
|
||||||
#+TITLE: Atomic Orbitals
|
|
||||||
|
|
||||||
#+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 files contains all the routines for the computation of the
|
This files contains all the routines for the computation of the
|
||||||
values, gradients and Laplacian of the atomic basis functions.
|
values, gradients and Laplacian of the atomic basis functions.
|
||||||
|
|
||||||
4 files are produced:
|
3 files are produced:
|
||||||
- a header file : =qmckl_ao.h=
|
|
||||||
- a source file : =qmckl_ao.f90=
|
- a source file : =qmckl_ao.f90=
|
||||||
- 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=
|
||||||
|
|
||||||
*** Header :noexport:
|
** Test :noexport:
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_ao.h
|
#+BEGIN_SRC C :tangle test_qmckl_ao.c
|
||||||
#ifndef QMCKL_AO_H
|
|
||||||
#define QMCKL_AO_H
|
|
||||||
#include "qmckl_context.h"
|
|
||||||
#include "qmckl_distance.h"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** Test :noexport:
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_ao.c
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "qmckl.h"
|
#include "qmckl.h"
|
||||||
#include "munit.h"
|
#include "munit.h"
|
||||||
@ -36,8 +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
|
||||||
@ -57,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 |
|
||||||
@ -73,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
|
||||||
@ -82,16 +64,16 @@ 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 :comments link :tangle qmckl_ao.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,
|
||||||
const double *X, const int32_t *LMAX,
|
const double *X, const int32_t *LMAX,
|
||||||
const double *P, const int64_t LDP);
|
const double *P, const int64_t LDP);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Source
|
**** Source
|
||||||
#+BEGIN_SRC f90 :comments link :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
|
||||||
integer*8 , intent(in) :: context
|
integer*8 , intent(in) :: context
|
||||||
@ -125,8 +107,8 @@ 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 :comments link :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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -143,7 +125,7 @@ integer(c_int32_t) function qmckl_ao_powers(context, n, X, LMAX, P, ldp) &
|
|||||||
end function qmckl_ao_powers
|
end function qmckl_ao_powers
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_ao.fh
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
interface
|
interface
|
||||||
integer(c_int32_t) function qmckl_ao_powers(context, n, X, LMAX, P, ldp) bind(C)
|
integer(c_int32_t) function qmckl_ao_powers(context, n, X, LMAX, P, ldp) bind(C)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -157,8 +139,8 @@ end function qmckl_ao_powers
|
|||||||
end interface
|
end interface
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Test :noexport:
|
**** Test :noexport:
|
||||||
#+BEGIN_SRC f90 :comments link :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
|
||||||
implicit none
|
implicit none
|
||||||
@ -203,18 +185,18 @@ integer(c_int32_t) function test_qmckl_ao_powers(context) bind(C)
|
|||||||
end function test_qmckl_ao_powers
|
end function test_qmckl_ao_powers
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_ao.c
|
#+BEGIN_SRC C :tangle test_qmckl_ao.c
|
||||||
int test_qmckl_ao_powers(qmckl_context context);
|
int test_qmckl_ao_powers(qmckl_context context);
|
||||||
munit_assert_int(0, ==, test_qmckl_ao_powers(context));
|
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 |
|
||||||
@ -226,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
|
||||||
@ -239,8 +221,8 @@ 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 :comments link :tangle qmckl_ao.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,
|
||||||
const int32_t lmax, const int64_t *n,
|
const int32_t lmax, const int64_t *n,
|
||||||
@ -248,8 +230,8 @@ 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 :comments link :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
|
||||||
integer*8 , intent(in) :: context
|
integer*8 , intent(in) :: context
|
||||||
@ -360,8 +342,8 @@ 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 :comments link :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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -380,7 +362,7 @@ integer(c_int32_t) function qmckl_ao_polynomial_vgl(context, X, R, lmax, n, L, l
|
|||||||
end function qmckl_ao_polynomial_vgl
|
end function qmckl_ao_polynomial_vgl
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_ao.fh
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
interface
|
interface
|
||||||
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)
|
bind(C)
|
||||||
@ -396,8 +378,8 @@ 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 :comments link :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
|
||||||
implicit none
|
implicit none
|
||||||
@ -492,17 +474,15 @@ integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
|
|||||||
end function test_qmckl_ao_polynomial_vgl
|
end function test_qmckl_ao_polynomial_vgl
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_ao.c
|
#+BEGIN_SRC C :tangle test_qmckl_ao.c
|
||||||
int test_qmckl_ao_polynomial_vgl(qmckl_context context);
|
int test_qmckl_ao_polynomial_vgl(qmckl_context context);
|
||||||
munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));
|
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:
|
||||||
@ -513,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 |
|
||||||
@ -523,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
|
||||||
@ -534,16 +514,16 @@ 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 :comments link :tangle qmckl_ao.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,
|
||||||
const int64_t *n, const int64_t *A,
|
const int64_t *n, const int64_t *A,
|
||||||
const double *VGL, const int64_t ldv);
|
const double *VGL, const int64_t ldv);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Source
|
**** Source
|
||||||
#+BEGIN_SRC f90 :comments link :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
|
||||||
integer*8 , intent(in) :: context
|
integer*8 , intent(in) :: context
|
||||||
@ -605,8 +585,8 @@ 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 :comments link :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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -623,7 +603,7 @@ integer(c_int32_t) function qmckl_ao_gaussians_vgl(context, X, R, n, A, VGL, ldv
|
|||||||
end function qmckl_ao_gaussians_vgl
|
end function qmckl_ao_gaussians_vgl
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_ao.fh
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
interface
|
interface
|
||||||
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)
|
bind(C)
|
||||||
@ -636,8 +616,8 @@ 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 :comments link :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
|
||||||
implicit none
|
implicit none
|
||||||
@ -704,27 +684,26 @@ integer(c_int32_t) function test_qmckl_ao_gaussians_vgl(context) bind(C)
|
|||||||
end function test_qmckl_ao_gaussians_vgl
|
end function test_qmckl_ao_gaussians_vgl
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_ao.c
|
#+BEGIN_SRC C :tangle test_qmckl_ao.c
|
||||||
int test_qmckl_ao_gaussians_vgl(qmckl_context context);
|
int test_qmckl_ao_gaussians_vgl(qmckl_context context);
|
||||||
munit_assert_int(0, ==, test_qmckl_ao_gaussians_vgl(context));
|
munit_assert_int(0, ==, test_qmckl_ao_gaussians_vgl(context));
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
* TODO Slater basis functions
|
** TODO Slater basis functions
|
||||||
|
|
||||||
* End of files :noexport:
|
** End of files :noexport:
|
||||||
|
|
||||||
*** Header
|
**** Test
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_ao.h
|
#+BEGIN_SRC C :tangle test_qmckl_ao.c
|
||||||
#endif
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** Test
|
|
||||||
#+BEGIN_SRC C :comments link :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;
|
||||||
return MUNIT_OK;
|
return MUNIT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
|
# -*- mode: org -*-
|
||||||
|
# vim: syntax=c
|
||||||
|
@ -1,43 +1,24 @@
|
|||||||
# -*- mode: org -*-
|
* Context
|
||||||
# vim: syntax=c
|
|
||||||
#+TITLE: Context
|
|
||||||
|
|
||||||
#+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 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.
|
||||||
|
|
||||||
3 files are produced:
|
2 files are produced:
|
||||||
- a header file : =qmckl_context.h=
|
|
||||||
- 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=
|
||||||
|
|
||||||
*** Header :noexport:
|
** Headers :noexport:
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||||
#ifndef QMCKL_CONTEXT_H
|
|
||||||
#define QMCKL_CONTEXT_H
|
|
||||||
#include "qmckl.h"
|
#include "qmckl.h"
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Source :noexport:
|
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
|
||||||
#include "qmckl.h"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** Test :noexport:
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
|
||||||
#include "qmckl.h"
|
#include "qmckl.h"
|
||||||
#include "munit.h"
|
#include "munit.h"
|
||||||
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
|
||||||
@ -46,8 +27,15 @@ MunitResult test_qmckl_context() {
|
|||||||
into a 64-bit signed integer, defined in the =qmckl_context= type.
|
into a 64-bit signed integer, defined in the =qmckl_context= type.
|
||||||
A value of 0 for the context is equivalent to a =NULL= pointer.
|
A value of 0 for the context is equivalent to a =NULL= pointer.
|
||||||
|
|
||||||
*** Source
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
#+END_SRC
|
||||||
|
|
||||||
|
**** Source
|
||||||
|
|
||||||
|
The tag is used internally to check if the memory domain pointed by
|
||||||
|
a pointer is a valid context.
|
||||||
|
|
||||||
|
#+BEGIN_SRC C :comments org :tangle qmckl_context.c
|
||||||
typedef struct qmckl_context_struct {
|
typedef struct qmckl_context_struct {
|
||||||
struct qmckl_context_struct * prev;
|
struct qmckl_context_struct * prev;
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
@ -59,29 +47,24 @@ typedef struct qmckl_context_struct {
|
|||||||
#define INVALID_TAG 0xDEADBEEF
|
#define INVALID_TAG 0xDEADBEEF
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
The tag is used internally to check if the memory domain pointed by
|
**** Test :noexport:
|
||||||
a pointer is a valid context.
|
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||||
|
|
||||||
*** Test :noexport:
|
|
||||||
We declare here the variables used in the tests.
|
|
||||||
#+BEGIN_SRC C :comments link :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.
|
||||||
|
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
|
||||||
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 :comments link :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) {
|
||||||
|
|
||||||
if (context == (qmckl_context) 0) return (qmckl_context) 0;
|
if (context == (qmckl_context) 0) return (qmckl_context) 0;
|
||||||
@ -94,19 +77,18 @@ 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
|
||||||
- Returns 0 upon failure to allocate the internal data structure
|
- Returns 0 upon failure to allocate the internal data structure
|
||||||
|
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
|
||||||
qmckl_context qmckl_context_create();
|
qmckl_context qmckl_context_create();
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Source
|
**** Source
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||||
qmckl_context qmckl_context_create() {
|
qmckl_context qmckl_context_create() {
|
||||||
|
|
||||||
qmckl_context_struct* context =
|
qmckl_context_struct* context =
|
||||||
@ -124,8 +106,8 @@ qmckl_context qmckl_context_create() {
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -133,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
|
||||||
@ -148,13 +130,12 @@ qmckl_context qmckl_context_create() {
|
|||||||
- Returns 0 upon failure to allocate the internal data structure
|
- Returns 0 upon failure to allocate the internal data structure
|
||||||
for the new context
|
for the new context
|
||||||
|
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
|
||||||
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 :comments link :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) {
|
||||||
|
|
||||||
const qmckl_context checked_context = qmckl_context_check(context);
|
const qmckl_context checked_context = qmckl_context_check(context);
|
||||||
@ -181,8 +162,8 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
|
|||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -191,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);
|
||||||
@ -199,20 +180,19 @@ qmckl_context qmckl_context_copy(const qmckl_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
|
||||||
- Returns 0 for the initial context
|
- Returns 0 for the initial context
|
||||||
- Returns 0 for the 0-valued context
|
- Returns 0 for the 0-valued context
|
||||||
|
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
|
||||||
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 :comments link :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) {
|
||||||
|
|
||||||
const qmckl_context checked_context = qmckl_context_check(context);
|
const qmckl_context checked_context = qmckl_context_check(context);
|
||||||
@ -225,8 +205,8 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -235,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);
|
||||||
@ -243,7 +223,7 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
|
|||||||
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
|
||||||
@ -251,13 +231,12 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
|
|||||||
- Fails if the 0-valued context is given in argument
|
- Fails if the 0-valued context is given in argument
|
||||||
- Fails if the the pointer is not a valid context
|
- Fails if the the pointer is not a valid context
|
||||||
|
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
|
||||||
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 :comments link :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) {
|
||||||
|
|
||||||
const qmckl_context checked_context = qmckl_context_check(context);
|
const qmckl_context checked_context = qmckl_context_check(context);
|
||||||
@ -272,8 +251,8 @@ qmckl_exit_code qmckl_context_destroy(const qmckl_context context) {
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -282,8 +261,8 @@ 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 :comments link :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);
|
||||||
munit_assert_int32(qmckl_context_destroy(new_context), ==, QMCKL_SUCCESS);
|
munit_assert_int32(qmckl_context_destroy(new_context), ==, QMCKL_SUCCESS);
|
||||||
@ -293,7 +272,7 @@ qmckl_exit_code qmckl_context_destroy(const qmckl_context context) {
|
|||||||
#+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
|
||||||
@ -303,14 +282,14 @@ qmckl_exit_code qmckl_context_destroy(const qmckl_context context) {
|
|||||||
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=
|
||||||
*** Header
|
Modifies the parameter for the numerical precision in a given context.
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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) {
|
||||||
|
|
||||||
if (precision < 2) return QMCKL_FAILURE;
|
if (precision < 2) return QMCKL_FAILURE;
|
||||||
@ -324,8 +303,8 @@ qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, cons
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -335,15 +314,15 @@ 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=
|
||||||
*** Header
|
Modifies the parameter for the numerical range in a given context.
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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) {
|
||||||
|
|
||||||
if (range < 2) return QMCKL_FAILURE;
|
if (range < 2) return QMCKL_FAILURE;
|
||||||
@ -357,8 +336,8 @@ qmckl_exit_code qmckl_context_update_range(const qmckl_context context, const in
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -368,15 +347,15 @@ 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=
|
||||||
*** Header
|
Returns a copy of the context with a different precision parameter.
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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);
|
||||||
if (new_context == 0) return 0;
|
if (new_context == 0) return 0;
|
||||||
@ -387,8 +366,8 @@ qmckl_context qmckl_context_set_precision(const qmckl_context context, const int
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -398,15 +377,15 @@ 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=
|
||||||
*** Header
|
Returns a copy of the context with a different precision parameter.
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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);
|
||||||
if (new_context == 0) return 0;
|
if (new_context == 0) return 0;
|
||||||
@ -417,8 +396,8 @@ qmckl_context qmckl_context_set_range(const qmckl_context context, const int ran
|
|||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -428,24 +407,24 @@ 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=
|
||||||
*** Header
|
Returns the value of the numerical precision in the context
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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;
|
||||||
return ctx->precision;
|
return ctx->precision;
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -454,23 +433,23 @@ 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=
|
||||||
*** Header
|
Returns the value of the numerical range in the context
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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;
|
||||||
return ctx->range;
|
return ctx->range;
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -479,25 +458,24 @@ 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
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.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 :comments link :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;
|
||||||
return 1.0 / ((double) ((int64_t) 1 << (ctx->precision-1)));
|
return 1.0 / ((double) ((int64_t) 1 << (ctx->precision-1)));
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Fortran interface
|
**** Fortran interface
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_context.fh
|
#+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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -506,24 +484,23 @@ 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:
|
||||||
|
|
||||||
*** Header
|
**** Test
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
|
||||||
#endif
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** 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;
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -*- mode: org -*-
|
||||||
|
# vim: syntax=c
|
||||||
|
@ -1,30 +1,13 @@
|
|||||||
# -*- mode: org -*-
|
* Computation of distances
|
||||||
# vim: syntax=c
|
|
||||||
#+TITLE: Computation of distances
|
|
||||||
|
|
||||||
#+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>
|
|
||||||
|
|
||||||
Function for the computation of distances between particles.
|
Function for the computation of distances between particles.
|
||||||
|
|
||||||
4 files are produced:
|
3 files are produced:
|
||||||
- a header file : =qmckl_distance.h=
|
|
||||||
- a source file : =qmckl_distance.f90=
|
- a source file : =qmckl_distance.f90=
|
||||||
- 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=
|
||||||
|
|
||||||
*** Header :noexport:
|
*** Headers :noexport:
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_distance.h
|
|
||||||
#ifndef QMCKL_DISTANCE_H
|
|
||||||
#define QMCKL_DISTANCE_H
|
|
||||||
#include "qmckl_context.h"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** Test :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"
|
||||||
@ -36,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:
|
||||||
@ -46,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 |
|
||||||
@ -60,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
|
||||||
@ -74,13 +57,12 @@ 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.
|
||||||
|
|
||||||
*** Header
|
#+BEGIN_SRC C :comments org :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_distance.h
|
|
||||||
qmckl_exit_code qmckl_distance_sq(const qmckl_context context,
|
qmckl_exit_code qmckl_distance_sq(const qmckl_context context,
|
||||||
const char transa, const char transb,
|
const char transa, const char transb,
|
||||||
const int64_t m, const int64_t n,
|
const int64_t m, const int64_t n,
|
||||||
@ -89,8 +71,8 @@ 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 :comments link :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
|
||||||
integer*8 , intent(in) :: context
|
integer*8 , intent(in) :: context
|
||||||
@ -217,8 +199,8 @@ 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 :comments link :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)
|
||||||
use, intrinsic :: iso_c_binding
|
use, intrinsic :: iso_c_binding
|
||||||
@ -238,7 +220,7 @@ integer(c_int32_t) function qmckl_distance_sq(context, transa, transb, m, n, A,
|
|||||||
end function qmckl_distance_sq
|
end function qmckl_distance_sq
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+BEGIN_SRC f90 :comments link :tangle qmckl_distance.fh
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
interface
|
interface
|
||||||
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)
|
bind(C)
|
||||||
@ -257,12 +239,11 @@ end function qmckl_distance_sq
|
|||||||
end interface
|
end interface
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Test :noexport:
|
**** Test :noexport:
|
||||||
#+BEGIN_SRC f90 :comments link :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, intrinsic :: iso_c_binding
|
use qmckl
|
||||||
implicit none
|
implicit none
|
||||||
include 'qmckl_distance.fh'
|
|
||||||
integer(c_int64_t), intent(in), value :: context
|
integer(c_int64_t), intent(in), value :: context
|
||||||
|
|
||||||
double precision, allocatable :: A(:,:), B(:,:), C(:,:)
|
double precision, allocatable :: A(:,:), B(:,:), C(:,:)
|
||||||
@ -361,14 +342,8 @@ 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:
|
||||||
|
|
||||||
*** Header
|
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_distance.h
|
|
||||||
#endif
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** Test
|
|
||||||
#+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)
|
||||||
return QMCKL_FAILURE;
|
return QMCKL_FAILURE;
|
||||||
@ -376,3 +351,7 @@ munit_assert_int(0, ==, test_qmckl_distance_sq(context));
|
|||||||
}
|
}
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
|
# -*- mode: org -*-
|
||||||
|
# vim: syntax=c
|
||||||
|
13
src/qmckl_footer.org
Normal file
13
src/qmckl_footer.org
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
* End of header files :noexport:
|
||||||
|
|
||||||
|
#+BEGIN_SRC C :tangle qmckl.h
|
||||||
|
#endif
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
|
end module qmckl
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
|
# -*- mode: org -*-
|
||||||
|
|
@ -1,52 +1,44 @@
|
|||||||
# -*- mode: org -*-
|
* Memory management
|
||||||
# vim: syntax=c
|
|
||||||
#+TITLE: Memory management
|
|
||||||
|
|
||||||
#+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>
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
3 files are produced:
|
2 files are produced:
|
||||||
- a header file : =qmckl_memory.h=
|
|
||||||
- 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=
|
||||||
|
|
||||||
** Header :noexport:
|
** Headers :noexport:
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
#+BEGIN_SRC C :tangle qmckl_memory.c
|
||||||
#ifndef QMCKL_MEMORY_H
|
|
||||||
#define QMCKL_MEMORY_H
|
|
||||||
#include "qmckl.h"
|
#include "qmckl.h"
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Source :noexport:
|
#+BEGIN_SRC C :tangle test_qmckl_memory.c
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.c
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "qmckl_memory.h"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Test :noexport:
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_memory.c
|
|
||||||
#include "qmckl.h"
|
#include "qmckl.h"
|
||||||
#include "munit.h"
|
#include "munit.h"
|
||||||
MunitResult test_qmckl_memory() {
|
MunitResult test_qmckl_memory() {
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* =qmckl_malloc=
|
** =qmckl_malloc=
|
||||||
Analogous of =malloc, but passing a context and a signed 64-bit integers as argument.=
|
|
||||||
** Header
|
Memory allocation function, letting the library choose how the
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
memory will be allocated, and a pointer is returned to the user.
|
||||||
|
|
||||||
|
#+BEGIN_SRC C :tangle qmckl.h
|
||||||
void* qmckl_malloc(const qmckl_context ctx, const size_t size);
|
void* qmckl_malloc(const qmckl_context ctx, const size_t size);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Source
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.c
|
interface
|
||||||
|
type (c_ptr) function qmckl_malloc (context, size) bind(C)
|
||||||
|
use, intrinsic :: iso_c_binding
|
||||||
|
integer (c_int64_t), intent(in), value :: context
|
||||||
|
integer (c_int64_t), intent(in), value :: size
|
||||||
|
end function qmckl_malloc
|
||||||
|
end interface
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** Source
|
||||||
|
#+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) {
|
||||||
/* Avoids unused parameter error */
|
/* Avoids unused parameter error */
|
||||||
@ -57,8 +49,8 @@ void* qmckl_malloc(const qmckl_context ctx, const size_t size) {
|
|||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Test :noexport:
|
*** Test :noexport:
|
||||||
#+BEGIN_SRC C :comments link :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));
|
||||||
a[0] = 1;
|
a[0] = 1;
|
||||||
@ -69,35 +61,41 @@ void* qmckl_malloc(const qmckl_context ctx, const size_t size) {
|
|||||||
munit_assert_int(a[2], ==, 3);
|
munit_assert_int(a[2], ==, 3);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* =qmckl_free=
|
** =qmckl_free=
|
||||||
|
|
||||||
** Header
|
#+BEGIN_SRC C :tangle qmckl.h
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
|
||||||
void qmckl_free(void *ptr);
|
void qmckl_free(void *ptr);
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Source
|
#+BEGIN_SRC f90 :tangle qmckl_f.f90
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.c
|
interface
|
||||||
|
subroutine qmckl_free (ptr) bind(C)
|
||||||
|
use, intrinsic :: iso_c_binding
|
||||||
|
type (c_ptr), intent(in), value :: ptr
|
||||||
|
end subroutine qmckl_free
|
||||||
|
end interface
|
||||||
|
#+END_SRC
|
||||||
|
*** Source
|
||||||
|
#+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 :comments link :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:
|
||||||
|
|
||||||
** Header
|
*** Test
|
||||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
#+BEGIN_SRC C :comments org :tangle test_qmckl_memory.c
|
||||||
#endif
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Test
|
|
||||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_memory.c
|
|
||||||
return MUNIT_OK;
|
return MUNIT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
|
# -*- mode: org -*-
|
||||||
|
# vim: syntax=c
|
||||||
|
Loading…
Reference in New Issue
Block a user