mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-23 04:44:03 +01:00
Added public get and set functions. #22
This commit is contained in:
parent
01516c84c5
commit
97ad53fd76
@ -168,7 +168,7 @@ typedef struct qmckl_jastrow_struct{
|
||||
double * tmp_c;
|
||||
double * dtmp_c;
|
||||
bool provided;
|
||||
char type;
|
||||
char * type;
|
||||
} qmckl_jastrow_struct;
|
||||
#+end_src
|
||||
|
||||
@ -180,7 +180,7 @@ typedef struct qmckl_jastrow_struct{
|
||||
Some values are initialized by default, and are not concerned by
|
||||
this mechanism.
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_private_func)
|
||||
#+begin_src c :comments org :tangle (eval h_func)
|
||||
qmckl_exit_code qmckl_init_jastrow(qmckl_context context);
|
||||
#+end_src
|
||||
|
||||
@ -203,17 +203,16 @@ qmckl_exit_code qmckl_init_jastrow(qmckl_context context) {
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
** Access functions
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_private_func) :exports none
|
||||
int64_t qmckl_get_jastrow_aord_num (qmckl_context context);
|
||||
int64_t qmckl_get_jastrow_bord_num (qmckl_context context);
|
||||
int64_t qmckl_get_jastrow_cord_num (qmckl_context context);
|
||||
int64_t qmckl_get_jastrow_type_nuc_num (qmckl_context context);
|
||||
double* qmckl_get_jastrow_aord_vector (qmckl_context context);
|
||||
double* qmckl_get_jastrow_bord_vector (qmckl_context context);
|
||||
double* qmckl_get_jastrow_cord_vector (qmckl_context context);
|
||||
#+begin_src c :comments org :tangle (eval h_func) :exports none
|
||||
qmckl_exit_code qmckl_get_jastrow_aord_num (qmckl_context context, int64_t* const aord_num);
|
||||
qmckl_exit_code qmckl_get_jastrow_bord_num (qmckl_context context, int64_t* const bord_num);
|
||||
qmckl_exit_code qmckl_get_jastrow_cord_num (qmckl_context context, int64_t* const bord_num);
|
||||
qmckl_exit_code qmckl_get_jastrow_type_nuc_num (qmckl_context context, int64_t* const type_nuc_num);
|
||||
qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector);
|
||||
qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector);
|
||||
qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector);
|
||||
#+end_src
|
||||
|
||||
Along with these core functions, calculation of the jastrow factor
|
||||
@ -249,12 +248,19 @@ if ( (ctx->jastrow.uninitialized & mask) != 0) {
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes :exports none
|
||||
int64_t qmckl_get_jastrow_aord_num (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_jastrow_aord_num (const qmckl_context context, int64_t* const aord_num) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (aord_num == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_aord_num",
|
||||
"aord_num is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
@ -265,34 +271,50 @@ int64_t qmckl_get_jastrow_aord_num (const qmckl_context context) {
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.aord_num > 0);
|
||||
return ctx->jastrow.aord_num;
|
||||
*aord_num = ctx->jastrow.aord_num;
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
int64_t qmckl_get_jastrow_bord_num (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_jastrow_bord_num (const qmckl_context context, int64_t* const bord_num) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (bord_num == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_bord_num",
|
||||
"aord_num is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
int32_t mask = 1 << 1;
|
||||
int32_t mask = 1 << 0;
|
||||
|
||||
if ( (ctx->jastrow.uninitialized & mask) != 0) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.bord_num > 0);
|
||||
return ctx->jastrow.bord_num;
|
||||
*bord_num = ctx->jastrow.bord_num;
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
int64_t qmckl_get_jastrow_cord_num (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_jastrow_cord_num (const qmckl_context context, int64_t* const cord_num) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (cord_num == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_cord_num",
|
||||
"aord_num is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
@ -303,15 +325,23 @@ int64_t qmckl_get_jastrow_cord_num (const qmckl_context context) {
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.cord_num > 0);
|
||||
return ctx->jastrow.cord_num;
|
||||
*cord_num = ctx->jastrow.cord_num;
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
int64_t qmckl_get_type_nuc_num (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_type_nuc_num (const qmckl_context context, int64_t* const type_nuc_num) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (type_nuc_num == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_type_nuc_num",
|
||||
"type_nuc_num is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
@ -322,15 +352,23 @@ int64_t qmckl_get_type_nuc_num (const qmckl_context context) {
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.type_nuc_num > 0);
|
||||
return ctx->jastrow.type_nuc_num;
|
||||
*type_nuc_num = ctx->jastrow.type_nuc_num;
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
double* qmckl_get_aord_vector (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_aord_vector (const qmckl_context context, double * const aord_vector) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (aord_vector == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_aord_vector",
|
||||
"aord_vector is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
@ -341,15 +379,23 @@ double* qmckl_get_aord_vector (const qmckl_context context) {
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.aord_vector != NULL);
|
||||
return ctx->jastrow.aord_vector;
|
||||
memcpy(aord_vector, ctx->jastrow.aord_vector, ctx->jastrow.aord_num*sizeof(double));
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
double* qmckl_get_bord_vector (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_bord_vector (const qmckl_context context, double * const bord_vector) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (bord_vector == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_bord_vector",
|
||||
"bord_vector is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
@ -360,15 +406,23 @@ double* qmckl_get_bord_vector (const qmckl_context context) {
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.bord_vector != NULL);
|
||||
return ctx->jastrow.bord_vector;
|
||||
memcpy(bord_vector, ctx->jastrow.bord_vector, ctx->jastrow.bord_num*sizeof(double));
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
double* qmckl_get_cord_vector (const qmckl_context context) {
|
||||
qmckl_exit_code qmckl_get_cord_vector (const qmckl_context context, double * const cord_vector) {
|
||||
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return (char) 0;
|
||||
}
|
||||
|
||||
if (cord_vector == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_get_jastrow_cord_vector",
|
||||
"cord_vector is a null pointer");
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct* const) context;
|
||||
assert (ctx != NULL);
|
||||
|
||||
@ -379,8 +433,10 @@ double* qmckl_get_cord_vector (const qmckl_context context) {
|
||||
}
|
||||
|
||||
assert (ctx->jastrow.cord_vector != NULL);
|
||||
return ctx->jastrow.cord_vector;
|
||||
memcpy(cord_vector, ctx->jastrow.cord_vector, ctx->jastrow.cord_num*sizeof(double));
|
||||
return QMCKL_SUCCESS;
|
||||
}
|
||||
|
||||
#+end_src
|
||||
|
||||
** Initialization functions
|
||||
@ -473,7 +529,10 @@ qmckl_exit_code qmckl_set_jastrow_aord_vector(qmckl_context context, double cons
|
||||
|
||||
int32_t mask = 1 << 3;
|
||||
|
||||
const int64_t aord_num = qmckl_get_jastrow_aord_num(context);
|
||||
int64_t aord_num;
|
||||
int rc = qmckl_get_jastrow_aord_num(context, &aord_num);
|
||||
if (rc != QMCKL_SUCCESS) return rc;
|
||||
|
||||
if (aord_num == 0) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_FAILURE,
|
||||
@ -520,7 +579,10 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons
|
||||
|
||||
int32_t mask = 1 << 4;
|
||||
|
||||
const int64_t bord_num = qmckl_get_jastrow_bord_num(context);
|
||||
int64_t bord_num;
|
||||
int rc = qmckl_get_jastrow_bord_num(context, &bord_num);
|
||||
if (rc != QMCKL_SUCCESS) return rc;
|
||||
|
||||
if (bord_num == 0) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_FAILURE,
|
||||
@ -557,7 +619,7 @@ qmckl_exit_code qmckl_set_jastrow_bord_vector(qmckl_context context, double cons
|
||||
|
||||
memcpy(new_array, bord_vector, mem_info.size);
|
||||
|
||||
ctx->jastrow.aord_vector = new_array;
|
||||
ctx->jastrow.bord_vector = new_array;
|
||||
|
||||
<<post2>>
|
||||
}
|
||||
@ -567,7 +629,10 @@ qmckl_exit_code qmckl_set_jastrow_cord_vector(qmckl_context context, double cons
|
||||
|
||||
int32_t mask = 1 << 5;
|
||||
|
||||
const int64_t cord_num = qmckl_get_jastrow_cord_num(context);
|
||||
int64_t cord_num;
|
||||
int rc = qmckl_get_jastrow_cord_num(context, &cord_num);
|
||||
if (rc != QMCKL_SUCCESS) return rc;
|
||||
|
||||
if (cord_num == 0) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_FAILURE,
|
||||
|
Loading…
Reference in New Issue
Block a user