1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 12:32:40 +01:00

Merge pull request #2 from TREX-CoE/const-qualifier

Use const qualifiers with qmckl_context
This commit is contained in:
Anthony Scemama 2020-10-15 12:10:08 +02:00 committed by GitHub
commit 2a484d96f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
# -*- mode: org -*-
#+TITLE: Context
#+TITLE: Context
This file is written in C because it is more natural to express the context in
C than in Fortran.
@ -17,7 +17,7 @@ C than in Fortran.
is stored in the following data structure, which can't be seen
outside of the library.
#+BEGIN_SRC C :tangle qmckl_context.h
#define QMCKL_DEFAULT_PRECISION 53
#define QMCKL_DEFAULT_RANGE 2
@ -66,11 +66,11 @@ qmckl_context qmckl_context_create() {
** =qmckl_context_copy=
#+BEGIN_SRC C :tangle qmckl_context.h
qmckl_context qmckl_context_copy(qmckl_context context);
qmckl_context qmckl_context_copy(const qmckl_context context);
#+END_SRC
#+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_copy(qmckl_context context) {
qmckl_context qmckl_context_copy(const qmckl_context context) {
qmckl_context_struct* old_context;
qmckl_context_struct* new_context;
@ -102,11 +102,11 @@ qmckl_context qmckl_context_copy(qmckl_context context) {
** =qmckl_context_set_precision=
#+BEGIN_SRC C :tangle qmckl_context.h
qmckl_context qmckl_context_set_precision(qmckl_context context, int precision);
qmckl_context qmckl_context_set_precision(const qmckl_context context, int precision);
#+END_SRC
#+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_set_precision(qmckl_context context, int precision) {
qmckl_context qmckl_context_set_precision(const qmckl_context context, int precision) {
qmckl_context_struct* ctx;
if (precision < 2) return (qmckl_context) 0;
@ -120,11 +120,11 @@ qmckl_context qmckl_context_set_precision(qmckl_context context, int precision)
** =qmckl_context_set_range=
#+BEGIN_SRC C :tangle qmckl_context.h
qmckl_context qmckl_context_set_range(qmckl_context context, int range);
qmckl_context qmckl_context_set_range(const qmckl_context context, int range);
#+END_SRC
#+BEGIN_SRC C :tangle qmckl_context.c
qmckl_context qmckl_context_set_range(qmckl_context context, int range) {
qmckl_context qmckl_context_set_range(const qmckl_context context, int range) {
qmckl_context_struct* ctx;
if (range < 2) return (qmckl_context) 0;
@ -141,11 +141,11 @@ qmckl_context qmckl_context_set_range(qmckl_context context, int range) {
** =qmckl_context_get_precision=
#+BEGIN_SRC C :tangle qmckl_context.h
int qmckl_context_get_precision(qmckl_context context);
int qmckl_context_get_precision(const qmckl_context context);
#+END_SRC
#+BEGIN_SRC C :tangle qmckl_context.c
int qmckl_context_get_precision(qmckl_context context) {
int qmckl_context_get_precision(const qmckl_context context) {
qmckl_context_struct* ctx;
ctx = (qmckl_context_struct*) context;
return ctx->precision;
@ -155,11 +155,11 @@ int qmckl_context_get_precision(qmckl_context context) {
** =qmckl_context_get_range=
#+BEGIN_SRC C :tangle qmckl_context.h
int qmckl_context_get_range(qmckl_context context);
int qmckl_context_get_range(const qmckl_context context);
#+END_SRC
#+BEGIN_SRC C :tangle qmckl_context.c
int qmckl_context_get_range(qmckl_context context) {
int qmckl_context_get_range(const qmckl_context context) {
qmckl_context_struct* ctx;
ctx = (qmckl_context_struct*) context;
return ctx->range;