diff --git a/README.html b/README.html index a8ba002..731636f 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + QMCkl source code documentation @@ -348,7 +348,7 @@ and bug reports should be submitted at

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/index.html b/index.html index a8ba002..731636f 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + QMCkl source code documentation @@ -348,7 +348,7 @@ and bug reports should be submitted at

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/qmckl.html b/qmckl.html index e2ad729..07239dd 100644 --- a/qmckl.html +++ b/qmckl.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Introduction @@ -333,30 +333,30 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 Using QMCkl

+
+

1 Using QMCkl

The qmckl.h header file has to be included in C codes when @@ -385,12 +385,12 @@ Both files are located in the include/ directory.

-
-

2 Developing in QMCkl

+
+

2 Developing in QMCkl

-
-

2.1 Literate programming

+
+

2.1 Literate programming

In a traditional source code, most of the lines of source files of a program @@ -436,8 +436,8 @@ interactively, in the same spirit as Jupyter notebooks.

-
-

2.2 Source code editing

+
+

2.2 Source code editing

For a tutorial on literate programming with org-mode, follow this link. @@ -469,8 +469,8 @@ org-mode.

-
-

2.3 Choice of the programming language

+
+

2.3 Choice of the programming language

Most of the codes of the TREX CoE are written in Fortran with some scripts in @@ -518,8 +518,8 @@ For more guidelines on using Fortran to generate a C interface, see

-
-

2.4 Coding rules

+
+

2.4 Coding rules

The authors should follow the recommendations of the @@ -535,8 +535,8 @@ freed

-
-

2.5 Design of the library

+
+

2.5 Design of the library

The proposed API should allow the library to: deal with memory transfers @@ -547,8 +547,8 @@ functions (see below).

-
-

2.6 Naming conventions

+
+

2.6 Naming conventions

To avoid namespace collisions, we use qmckl_ as a prefix for all exported @@ -573,8 +573,8 @@ form is allowed.

-
-

2.7 Application programming interface

+
+

2.7 Application programming interface

In the C language, the number of bits used by the integer types can change @@ -607,15 +607,15 @@ bindings in other languages in other repositories.

-
-

2.8 Global state

+
+

2.8 Global state

Global variables should be avoided in the library, because it is possible that one single program needs to use multiple instances of the library. To solve this problem we propose to use a pointer to a context variable, built by the library with the -qmckl_context_create function. The =context= contains the global +qmckl_context_create function. The =context= contains the global state of the library, and is used as the first argument of many QMCkl functions.

@@ -635,8 +635,8 @@ versions can be destroyed with qmckl_context_destroy.
-
-

2.9 Low-level functions

+
+

2.9 Low-level functions

Low-level functions are very simple functions which are leaves of @@ -645,14 +645,14 @@ the function call tree (they don't call any other QMCkl function).

These functions are pure, and unaware of the QMCkl -context. They are not allowed to allocate/deallocate memory, and +context. They are not allowed to allocate/deallocate memory, and if they need temporary memory it should be provided in input.

-
-

2.10 High-level functions

+
+

2.10 High-level functions

High-level functions are at the top of the function call tree. @@ -665,27 +665,27 @@ temporary storage, to simplify the use of accelerators.

The high-level functions should be pure, unless the introduction of non-purity is justified. All the side effects should be made in -the context variable. +the context variable.

-
-

2.11 Numerical precision

+
+

2.11 Numerical precision

The number of bits of precision required for a function should be given as an input of low-level computational functions. This input will be used to define the values of the different thresholds that might be used to avoid computing unnecessary noise. High-level -functions will use the precision specified in the context +functions will use the precision specified in the context variable.

-
-

2.12 Algorithms

+
+

2.12 Algorithms

Reducing the scaling of an algorithm usually implies also reducing @@ -698,8 +698,8 @@ implemented adapted to different problem sizes.

-
-

2.13 Rules for the API

+
+

2.13 Rules for the API

  • stdint should be used for integers (int32_t, int64_t)
  • @@ -713,7 +713,7 @@ implemented adapted to different problem sizes.

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/qmckl_ao.html b/qmckl_ao.html index 43800bb..fdad1c1 100644 --- a/qmckl_ao.html +++ b/qmckl_ao.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Atomic Orbitals @@ -333,14 +333,14 @@ for the JavaScript code in this tag.

Table of Contents

@@ -389,12 +389,12 @@ In this section we describe the kernels used to compute the values, gradients and Laplacian of the atomic basis functions.

-
-

1 Polynomial part

+
+

1 Polynomial part

-
-

1.1 Powers of \(x-X_i\)

+
+

1.1 Powers of \(x-X_i\)

The qmckl_ao_power function computes all the powers of the n @@ -574,8 +574,8 @@ Requirements:

-
-

1.2 Value, Gradient and Laplacian of a polynomial

+
+

1.2 Value, Gradient and Laplacian of a polynomial

A polynomial is centered on a nucleus \(\mathbf{R}_i\) @@ -960,8 +960,8 @@ munit_assert_int(0, ==, test_qmckl_ao_polynomial_vgl(context));

-
-

2 Gaussian basis functions

+
+

2 Gaussian basis functions

qmckl_ao_gaussian_vgl computes the values, gradients and @@ -1193,13 +1193,13 @@ Requirements :

-
-

3 TODO Slater basis functions

+
+

3 TODO Slater basis functions

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/qmckl_context.html b/qmckl_context.html index ee4e1d0..8ed4dee 100644 --- a/qmckl_context.html +++ b/qmckl_context.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Context @@ -333,51 +333,51 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 Context handling

+
+

1 Context handling

The context appears as an immutable data structure: modifying a @@ -419,8 +419,8 @@ and ctx is a qmckl_context_struct* pointer.

-
-

1.1 Data structure

+
+

1.1 Data structure

The main data structure contains pointers to other data structures, @@ -430,7 +430,7 @@ pointers.

-
typedef struct qmckl_context_struct {
+
typedef struct qmckl_context_struct {
 
   /* Pointer to the previous context, before modification */
   struct qmckl_context_struct * prev;
@@ -510,8 +510,8 @@ if the context is valid, QMCKL_NULL_CONTEXT otherwise.
 
-
-

1.2 Creation

+
+

1.2 Creation

To create a new context, qmckl_context_create() should be used. @@ -549,8 +549,8 @@ To create a new context, qmckl_context_create() should be used.

-
-

1.3 Access to the previous context

+
+

1.3 Access to the previous context

qmckl_context_previous returns the previous context. It returns @@ -572,8 +572,8 @@ To create a new context, qmckl_context_create() should be used.

-
-

1.4 Locking

+
+

1.4 Locking

For thread safety, the context may be locked/unlocked. The lock is @@ -633,8 +633,8 @@ number of times the thread has locked it is saved in the

-
-

1.5 Copy

+
+

1.5 Copy

qmckl_context_copy makes a shallow copy of a context. It returns @@ -680,8 +680,8 @@ number of times the thread has locked it is saved in the

-
-

1.6 Destroy

+
+

1.6 Destroy

The context is destroyed with qmckl_context_destroy, leaving the ancestors untouched. @@ -741,12 +741,12 @@ It frees the context, and returns the previous context.

-
-

2 Memory allocation handling

+
+

2 Memory allocation handling

-
-

2.1 Data structure

+
+

2.1 Data structure

Pointers to all allocated memory domains are stored in the context, @@ -755,7 +755,7 @@ computation of the amount of currently used memory by the library.

-
typedef struct qmckl_memory_struct {
+
typedef struct qmckl_memory_struct {
   struct qmckl_memory_struct * next    ;
   void                       * pointer ;
   size_t                       size    ;
@@ -765,8 +765,8 @@ computation of the amount of currently used memory by the library.
 
-
-

2.2 Append memory

+
+

2.2 Append memory

The following function, called in qmckl_memory.c, appends a new @@ -824,8 +824,8 @@ immediately with QMCKL_SUCCESS.

-
-

2.3 Remove memory

+
+

2.3 Remove memory

The following function, called in qmckl_memory.c, removes a @@ -876,15 +876,15 @@ immediately with QMCKL_SUCCESS.

-
-

3 Error handling

+
+

3 Error handling

-
-

3.1 Data structure

+
+

3.1 Data structure

-
#define  QMCKL_MAX_FUN_LEN   256
+
#define  QMCKL_MAX_FUN_LEN   256
 #define  QMCKL_MAX_MSG_LEN  1024
 
 typedef struct qmckl_error_struct {
@@ -899,8 +899,8 @@ immediately with QMCKL_SUCCESS.
 
-
-

3.2 Updating errors

+
+

3.2 Updating errors

The error is updated in the context using @@ -1049,8 +1049,8 @@ For example, this function can be used as

-
-

4 Control of the numerical precision

+
+

4 Control of the numerical precision

Controlling numerical precision enables optimizations. Here, the @@ -1058,7 +1058,7 @@ default parameters determining the target numerical precision and range are defined.

- +
@@ -1104,7 +1104,7 @@ range are defined.
-
typedef struct qmckl_precision_struct {
+
typedef struct qmckl_precision_struct {
   int  precision;
   int  range;
 } qmckl_precision_struct;
@@ -1125,8 +1125,8 @@ integer. The update functions return QMCKL_SUCCESS or
 

-
-

4.1 Precision

+
+

4.1 Precision

qmckl_context_update_precision modifies the parameter for the @@ -1248,8 +1248,8 @@ different precision parameter.

-
-

4.2 Range

+
+

4.2 Range

qmckl_context_update_range modifies the parameter for the numerical range in a given context. @@ -1357,8 +1357,8 @@ different precision parameter.

-
-

4.3 Helper functions

+
+

4.3 Helper functions

qmckl_context_get_epsilon returns \(\epsilon = 2^{1-n}\) where n is the precision. @@ -1374,8 +1374,8 @@ different precision parameter.

-
-

5 TODO Basis set

+
+

5 TODO Basis set

For H2 with the following basis set, @@ -1422,11 +1422,11 @@ COEFFICIENT = [ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421,

-
-

5.1 Data structure

+
+

5.1 Data structure

-
typedef struct qmckl_ao_basis_struct {
+
typedef struct qmckl_ao_basis_struct {
 
   int64_t   shell_num;
   int64_t   prim_num;
@@ -1444,8 +1444,8 @@ COEFFICIENT = [ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421,
 
-
-

5.2 qmckl_context_update_ao_basis

+
+

5.2 qmckl_context_update_ao_basis

Updates the data describing the AO basis set into the context. @@ -1529,8 +1529,8 @@ Updates the data describing the AO basis set into the context.

-
-

5.2.1 Source

+
+

5.2.1 Source

qmckl_exit_code
@@ -1677,8 +1677,8 @@ Updates the data describing the AO basis set into the context.
 
-
-

5.2.2 Fortran interface

+
+

5.2.2 Fortran interface

interface
@@ -1704,13 +1704,13 @@ Updates the data describing the AO basis set into the context.
 
-
-

5.2.3 TODO Test

+
+

5.2.3 TODO Test

-
-

5.3 qmckl_context_set_ao_basis

+
+

5.3 qmckl_context_set_ao_basis

Sets the data describing the AO basis set into the context. @@ -1789,8 +1789,8 @@ Sets the data describing the AO basis set into the context.

-
-

5.3.1 Source

+
+

5.3.1 Source

qmckl_context
@@ -1819,8 +1819,8 @@ Sets the data describing the AO basis set into the context.
 
-
-

5.3.2 Fortran interface

+
+

5.3.2 Fortran interface

interface
@@ -1846,15 +1846,15 @@ Sets the data describing the AO basis set into the context.
 
-
-

5.3.3 TODO Test

+
+

5.3.3 TODO Test

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/qmckl_distance.html b/qmckl_distance.html new file mode 100644 index 0000000..4b29225 --- /dev/null +++ b/qmckl_distance.html @@ -0,0 +1,658 @@ + + + + + + + +Inter-particle distances + + + + + + + + + + + + + +
+ UP + | + HOME +
+

Inter-particle distances

+ +

+Functions for the computation of distances between particles. +

+ +
+

1 Squared distance

+
+
+
+

1.1 qmckl_distance_sq

+
+

+qmckl_distance_sq computes the matrix of the squared distances +between all pairs of points in two sets, one point within each set: +

+ +

+\[ + C_{ij} = \sum_{k=1}^3 (A_{k,i}-B_{k,j})^2 + \] +

+ +
+ + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
qmcklcontextcontextinGlobal state
chartransainArray A is 'N': Normal, 'T': Transposed
chartransbinArray B is 'N': Normal, 'T': Transposed
int64tminNumber of points in the first set
int64tninNumber of points in the second set
doubleA[3][lda]inArray containing the \(m \times 3\) matrix \(A\)
int64tldainLeading dimension of array A
doubleB[3][ldb]inArray containing the \(n \times 3\) matrix \(B\)
int64tldbinLeading dimension of array B
doubleC[n][ldc]outArray containing the \(m \times n\) matrix \(C\)
int64tldcinLeading dimension of array C
+
+ +
+

1.1.1 Requirements

+
+
    +
  • context is not QMCKL_NULL_CONTEXT
  • +
  • m > 0
  • +
  • n > 0
  • +
  • lda >= 3 if transa == 'N'
  • +
  • lda >= m if transa == 'T'
  • +
  • ldb >= 3 if transb == 'N'
  • +
  • ldb >= n if transb == 'T'
  • +
  • ldc >= m
  • +
  • A is allocated with at least \(3 \times m \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
  • +
+
+
+ +
+

1.1.2 C header

+
+
+
qmckl_exit_code qmckl_distance_sq (
+              const qmckl_context context,
+      const char transa,
+      const char transb,
+      const int64_t m,
+      const int64_t n,
+      const double* A,
+      const int64_t lda,
+      const double* B,
+      const int64_t ldb,
+            double* C,
+      const int64_t ldc ); 
+
+
+
+
+ +
+

1.1.3 Source

+
+
+
integer function qmckl_distance_sq_f(context, transa, transb, m, n, A, LDA, B, LDB, C, LDC) result(info)
+  use qmckl
+  implicit none
+  integer*8  , intent(in)  :: context
+  character  , intent(in)  :: transa, transb
+  integer*8  , intent(in)  :: m, n
+  integer*8  , intent(in)  :: lda
+  real*8     , intent(in)  :: A(lda,*)
+  integer*8  , intent(in)  :: ldb
+  real*8     , intent(in)  :: B(ldb,*)
+  integer*8  , intent(in)  :: ldc
+  real*8     , intent(out) :: C(ldc,*)
+
+  integer*8 :: i,j
+  real*8    :: x, y, z
+  integer   :: transab
+
+  info = 0
+
+  if (context == QMCKL_NULL_CONTEXT) then
+     info = QMCKL_INVALID_CONTEXT
+     return
+  endif
+
+  if (m <= 0_8) then
+     info = QMCKL_INVALID_ARG_4
+     return
+  endif
+
+  if (n <= 0_8) then
+     info = QMCKL_INVALID_ARG_5
+     return
+  endif
+
+  if (transa == 'N' .or. transa == 'n') then
+     transab = 0
+  else if (transa == 'T' .or. transa == 't') then
+     transab = 1
+  else
+     transab = -100
+  endif
+
+  if (transb == 'N' .or. transb == 'n') then
+     continue
+  else if (transa == 'T' .or. transa == 't') then
+     transab = transab + 2
+  else
+     transab = -100
+  endif
+
+  if (transab < 0) then
+     info = QMCKL_INVALID_ARG_1
+     return 
+  endif
+
+  if (iand(transab,1) == 0 .and. LDA < 3) then
+     info = QMCKL_INVALID_ARG_7
+     return
+  endif
+
+  if (iand(transab,1) == 1 .and. LDA < m) then
+     info = QMCKL_INVALID_ARG_7
+     return
+  endif
+
+  if (iand(transab,2) == 0 .and. LDA < 3) then
+     info = QMCKL_INVALID_ARG_7
+     return
+  endif
+
+  if (iand(transab,2) == 2 .and. LDA < m) then
+     info = QMCKL_INVALID_ARG_7
+     return
+  endif
+
+
+  select case (transab)
+
+  case(0)
+
+     do j=1,n
+        do i=1,m
+           x = A(1,i) - B(1,j)
+           y = A(2,i) - B(2,j)
+           z = A(3,i) - B(3,j)
+           C(i,j) = x*x + y*y + z*z
+        end do
+     end do
+
+  case(1)
+
+     do j=1,n
+        do i=1,m
+           x = A(i,1) - B(1,j)
+           y = A(i,2) - B(2,j)
+           z = A(i,3) - B(3,j)
+           C(i,j) = x*x + y*y + z*z
+        end do
+     end do
+
+  case(2)
+
+     do j=1,n
+        do i=1,m
+           x = A(1,i) - B(j,1)
+           y = A(2,i) - B(j,2)
+           z = A(3,i) - B(j,3)
+           C(i,j) = x*x + y*y + z*z
+        end do
+     end do
+
+  case(3)
+
+     do j=1,n
+        do i=1,m
+           x = A(i,1) - B(j,1)
+           y = A(i,2) - B(j,2)
+           z = A(i,3) - B(j,3)
+           C(i,j) = x*x + y*y + z*z
+        end do
+     end do
+
+  end select
+
+end function qmckl_distance_sq_f
+
+
+
+
+ +
+

1.1.4 Performance

+
+

+This function might be more efficient when A and B are +transposed. +

+
+
+
+
+
+
+

Author: TREX CoE

+

Created: 2021-03-23 Tue 21:25

+

Validate

+
+ + diff --git a/qmckl_error.html b/qmckl_error.html index 33fcad0..308b71f 100644 --- a/qmckl_error.html +++ b/qmckl_error.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Error handling @@ -311,14 +311,14 @@ for the JavaScript code in this tag.

Table of Contents

    -
  • +
-
-

-
+
+

+

The library should never make the calling programs abort, nor perform any input/output operations. This decision has to be taken @@ -329,7 +329,7 @@ by the developer of the code calling the library. All the functions return with an exit code, defined as

-
typedef int32_t qmckl_exit_code;
+
typedef int32_t qmckl_exit_code;
 
@@ -345,7 +345,7 @@ error code is returned to the program. Here is the complete list of exit codes.

- +
@@ -558,7 +558,7 @@ The text strings are extracted from the previous table.

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/qmckl_memory.html b/qmckl_memory.html index 4173953..cb74ed5 100644 --- a/qmckl_memory.html +++ b/qmckl_memory.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - +Memory management @@ -311,7 +311,7 @@ for the JavaScript code in this tag.

Table of Contents

    -
  • +
@@ -321,9 +321,9 @@ optimized libraries to fine-tune the memory allocation.

-
-

-
+
+

+

Memory allocation inside the library should be done with qmckl_malloc. It lets the library choose how the memory will be @@ -434,7 +434,7 @@ allocation and needs to be updated.

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate

diff --git a/test_qmckl.html b/test_qmckl.html index 86dda10..9b4f088 100644 --- a/test_qmckl.html +++ b/test_qmckl.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Testing @@ -311,7 +311,7 @@ for the JavaScript code in this tag.

Author: TREX CoE

-

Created: 2021-03-20 Sat 15:59

+

Created: 2021-03-23 Tue 21:25

Validate