diff --git a/process.py b/process.py new file mode 100644 index 0000000..c03882b --- /dev/null +++ b/process.py @@ -0,0 +1,182 @@ + +import os + + +collect = False +process = False +get_name = False +block = [] +res_str = '' +func_name = '' +arrays = {} +numbers = {} +qmckl_public_api = [] + + +with open("include/qmckl.h", 'r') as f_in: + for line in f_in: + + if get_name: + words = line.strip().split() + if '(' in words[0]: + func_name = words[0].split('(')[0] + else: + func_name = words[0] + if 'get' in func_name or 'set' in func_name: + qmckl_public_api.append(func_name) + + get_name = False + + if 'qmckl_exit_code' in line: + words = line.strip().split() + if len(words) > 1 and 'qmckl_exit_code' in words[0]: + # this means that the function name is on the same line as `qmckl_exit_code` + func_name = words[1].split('(')[0] + if 'get' in func_name or 'set' in func_name: + qmckl_public_api.append(func_name) + elif len(words) == 1: + # this means that the function name is the first element on the next line + get_name = True + #continue # do not `continue` here otherwise collect is not True for some functions + + # process functions - oneliners (for arrays) + if 'size_max' in line and ';' in line: + + tmp_list = line.split(',') + for i,s in enumerate(tmp_list): + if 'size_max' in s: + end_str = tmp_list[i].replace(';','').replace('\n','') + pattern = f"({tmp_list[i-1]} ,{end_str}" + datatype = tmp_list[i-1].replace('const','').replace('*','').split()[0] + arrays[func_name] = { + 'datatype' : datatype, + 'pattern' : pattern + } + #if 'qmckl_get_jastrow_type_nucl_vector' in func_name: + # print(line) + # print(pattern) + continue + + # if size_max is not provided then the function should deal with numbers or string + #elif 'num' in line and 'get' in func_name: + elif ';' in line and 'get' in func_name: + # special case + if 'size_max' in line: + continue + + #print(line) + + tmp_str = line.split(',')[-1].strip() + + pattern = tmp_str.replace(')','').replace(';','') + datatype = pattern.replace('const','').replace('*','').split()[0] + + numbers[func_name] = { + 'datatype' : datatype, + 'pattern' : pattern + } + continue + # for multilne functions - append line by line to the list + else: + block.append(line) + collect = True + continue + + # if size_max is encountered within the multiline function + if 'size_max' in line and collect: + #if 'qmckl_get_electron_rescale_factor_en' in func_name: + # print("LOL") + + # this will not work for 2-line functions where array argument is on the same line as + # func name and size_max argument is on the next line + if not 'qmckl_exit_code' in block[-1] and not '*/' in line: + pattern = '(' + block[-1].strip() + line.strip().replace(';','') + datatype = pattern.replace('const','').replace('*','').replace('(','').split()[0] + + collect = False + block = [] + arrays[func_name] = { + 'datatype' : datatype, + 'pattern' : pattern + } + continue + + #if 'num' in line and 'get' in func_name and not 'qmckl_get' in line and collect: + if 'get' in func_name and not 'qmckl_get' in line and collect and ';' in line: + + print(func_name) + print(line) + + pattern = line.replace(';','').replace(')','').strip() + datatype = pattern.replace('const','').replace('*','').split()[0] + + collect = False + block = [] + numbers[func_name] = { + 'datatype' : datatype, + 'pattern' : pattern + } + continue + + # stop/continue multiline function analyzer + if collect and ')' in line: + collect = False + block = [] + continue + else: + block.append(line) + continue + + +# remove buggy qmckl_get_electron_rescale_factor_en key +#arrays.pop('qmckl_get_electron_rescale_factor_en') + +processed = list(arrays.keys()) + list(numbers.keys()) + +for pub_func in qmckl_public_api: + if pub_func not in processed and 'set' not in pub_func: + print("TODO", pub_func) + #print(v['datatype']) + + +for k,v in numbers.items(): + print(v) + + +with open("python/pyqmckl_include.i", 'w') as f_out: + + swig_type = '' + for v in numbers.values(): + + if 'int' in v['datatype']: + swig_type = 'int' + elif 'float' in v['datatype'] or 'double' in v['datatype']: + swig_type = 'float' + elif 'char' in v['datatype'] or 'bool' in v['datatype']: + print('SWIG, skipping') + continue + else: + raise TypeError(f"Unknown datatype for swig conversion: {v['datatype']}") + + f_out.write(f"%apply {swig_type} *OUTPUT {{ {v['pattern']} }};\n") + + for k,v in arrays.items(): + if 'char' in v['datatype']: + print("String type") + pass + + if len(v['pattern'].split(',')) != 2: + print('Problemo', k, v) + continue + + if 'get' in k: + f_out.write(f"%apply ( {v['datatype']}* ARGOUT_ARRAY1 , int64_t DIM1 ) {{ {v['pattern']} }};\n") + elif 'set' in k: + f_out.write(f"%apply ( {v['datatype']}* IN_ARRAY1 , int64_t DIM1 ) {{ {v['pattern']} }};\n") + else: + print("HOW-TO ?", k) + + + + + diff --git a/python/build_pyqmckl.sh b/python/build_pyqmckl.sh new file mode 100755 index 0000000..13d934f --- /dev/null +++ b/python/build_pyqmckl.sh @@ -0,0 +1,18 @@ + +set -e +set -x + +source export_files.sh + +cp qmckl.h pyqmckl.i numpy.i src/ + +cd src/ + +swig -python -py3 -o pyqmckl_wrap.c pyqmckl.i + +gcc -c -fPIC -I/usr/include/python3.8 ${C_FILES} pyqmckl_wrap.c -ltrexio + +gfortran -c -fPIC -I/usr/include/python3.8 ${F_FILES} + +gcc -shared ${C_O_FILES} pyqmckl_wrap.o -o _pyqmckl.so + diff --git a/python/export_files.sh b/python/export_files.sh new file mode 100644 index 0000000..e9d26f3 --- /dev/null +++ b/python/export_files.sh @@ -0,0 +1,11 @@ + +export C_FILES="qmckl_electron.c qmckl_nucleus.c qmckl_determinant.c qmckl_error.c qmckl_verificarlo.c qmckl_jastrow.c qmckl_sherman_morrison_woodbury.c qmckl_trexio.c qmckl_numprec.c qmckl_context.c qmckl_mo.c qmckl_blas.c qmckl_memory.c qmckl_local_energy.c qmckl_point.c qmckl_ao.c" +export F_FILES="qmckl_electron_f.F90 qmckl_distance_f.F90 qmckl_nucleus_f.F90 qmckl_determinant_f.F90 qmckl_verificarlo_f.F90 qmckl_jastrow_f.F90 qmckl_mo_f.F90 qmckl_blas_f.F90 qmckl_local_energy_f.F90 qmckl_ao_f.F90" +export C_O_FILES="qmckl_electron.o qmckl_nucleus.o qmckl_determinant.o qmckl_error.o qmckl_verificarlo.o qmckl_jastrow.o qmckl_sherman_morrison_woodbury.o qmckl_trexio.o qmckl_numprec.o qmckl_context.o qmckl_mo.o qmckl_blas.o qmckl_memory.o qmckl_local_energy.o qmckl_point.o qmckl_ao.o" +export FH_FUNC_FILES="qmckl_electron_fh_func.F90 qmckl_distance_fh_func.F90 qmckl_nucleus_fh_func.F90 qmckl_error_fh_func.F90 qmckl_sherman_morrison_woodbury_fh_func.F90 qmckl_trexio_fh_func.F90 qmckl_numprec_fh_func.F90 qmckl_context_fh_func.F90 qmckl_mo_fh_func.F90 qmckl_blas_fh_func.F90 qmckl_point_fh_func.F90 qmckl_ao_fh_func.F90" +export FH_TYPE_FILES="qmckl_error_fh_type.F90 qmckl_context_fh_type.F90" +export H_FUNC_FILES="qmckl_electron_func.h qmckl_distance_func.h qmckl_nucleus_func.h qmckl_determinant_func.h qmckl_error_func.h qmckl_jastrow_func.h qmckl_sherman_morrison_woodbury_func.h qmckl_trexio_func.h qmckl_numprec_func.h qmckl_context_func.h qmckl_mo_func.h qmckl_blas_func.h qmckl_local_energy_func.h qmckl_point_func.h qmckl_ao_func.h" +export H_TYPE_FILES="qmckl_error_type.h qmckl_numprec_type.h qmckl_context_type.h" +export H_PRIVATE_FUNC_FILES="qmckl_electron_private_func.h qmckl_nucleus_private_func.h qmckl_determinant_private_func.h qmckl_error_private_func.h qmckl_verificarlo_private_func.h qmckl_jastrow_private_func.h qmckl_mo_private_func.h qmckl_blas_private_func.h qmckl_memory_private_func.h qmckl_local_energy_private_func.h qmckl_point_private_func.h qmckl_ao_private_func.h" +export H_PRIVATE_TYPE_FILES="qmckl_electron_private_type.h qmckl_nucleus_private_type.h qmckl_determinant_private_type.h qmckl_error_private_type.h qmckl_jastrow_private_type.h qmckl_numprec_private_type.h qmckl_context_private_type.h qmckl_mo_private_type.h qmckl_blas_private_type.h qmckl_memory_private_type.h qmckl_local_energy_private_type.h qmckl_point_private_type.h qmckl_ao_private_type.h" + diff --git a/python/export_files_with_src_prefix.sh b/python/export_files_with_src_prefix.sh new file mode 100644 index 0000000..7073cf6 --- /dev/null +++ b/python/export_files_with_src_prefix.sh @@ -0,0 +1,11 @@ + +export C_FILES="src/qmckl_electron.c src/qmckl_nucleus.c src/qmckl_determinant.c src/qmckl_error.c src/qmckl_verificarlo.c src/qmckl_jastrow.c src/qmckl_sherman_morrison_woodbury.c src/qmckl_trexio.c src/qmckl_numprec.c src/qmckl_context.c src/qmckl_mo.c src/qmckl_blas.c src/qmckl_memory.c src/qmckl_local_energy.c src/qmckl_point.c src/qmckl_ao.c" +export F_FILES="src/qmckl_electron_f.F90 src/qmckl_distance_f.F90 src/qmckl_nucleus_f.F90 src/qmckl_determinant_f.F90 src/qmckl_verificarlo_f.F90 src/qmckl_jastrow_f.F90 src/qmckl_mo_f.F90 src/qmckl_blas_f.F90 src/qmckl_local_energy_f.F90 src/qmckl_ao_f.F90" +export C_O_FILES="src/qmckl_electron.o src/qmckl_nucleus.o src/qmckl_determinant.o src/qmckl_error.o src/qmckl_verificarlo.o src/qmckl_jastrow.o src/qmckl_sherman_morrison_woodbury.o src/qmckl_trexio.o src/qmckl_numprec.o src/qmckl_context.o src/qmckl_mo.o src/qmckl_blas.o src/qmckl_memory.o src/qmckl_local_energy.o src/qmckl_point.o src/qmckl_ao.o" +export FH_FUNC_FILES="src/qmckl_electron_fh_func.F90 src/qmckl_distance_fh_func.F90 src/qmckl_nucleus_fh_func.F90 src/qmckl_error_fh_func.F90 src/qmckl_sherman_morrison_woodbury_fh_func.F90 src/qmckl_trexio_fh_func.F90 src/qmckl_numprec_fh_func.F90 src/qmckl_context_fh_func.F90 src/qmckl_mo_fh_func.F90 src/qmckl_blas_fh_func.F90 src/qmckl_point_fh_func.F90 src/qmckl_ao_fh_func.F90" +export FH_TYPE_FILES="src/qmckl_error_fh_type.F90 src/qmckl_context_fh_type.F90" +export H_FUNC_FILES="src/qmckl_electron_func.h src/qmckl_distance_func.h src/qmckl_nucleus_func.h src/qmckl_determinant_func.h src/qmckl_error_func.h src/qmckl_jastrow_func.h src/qmckl_sherman_morrison_woodbury_func.h src/qmckl_trexio_func.h src/qmckl_numprec_func.h src/qmckl_context_func.h src/qmckl_mo_func.h src/qmckl_blas_func.h src/qmckl_local_energy_func.h src/qmckl_point_func.h src/qmckl_ao_func.h" +export H_TYPE_FILES="src/qmckl_error_type.h src/qmckl_numprec_type.h src/qmckl_context_type.h" +export H_PRIVATE_FUNC_FILES="src/qmckl_electron_private_func.h src/qmckl_nucleus_private_func.h src/qmckl_determinant_private_func.h src/qmckl_error_private_func.h src/qmckl_verificarlo_private_func.h src/qmckl_jastrow_private_func.h src/qmckl_mo_private_func.h src/qmckl_blas_private_func.h src/qmckl_memory_private_func.h src/qmckl_local_energy_private_func.h src/qmckl_point_private_func.h src/qmckl_ao_private_func.h" +export H_PRIVATE_TYPE_FILES="src/qmckl_electron_private_type.h src/qmckl_nucleus_private_type.h src/qmckl_determinant_private_type.h src/qmckl_error_private_type.h src/qmckl_jastrow_private_type.h src/qmckl_numprec_private_type.h src/qmckl_context_private_type.h src/qmckl_mo_private_type.h src/qmckl_blas_private_type.h src/qmckl_memory_private_type.h src/qmckl_local_energy_private_type.h src/qmckl_point_private_type.h src/qmckl_ao_private_type.h" + diff --git a/python/numpy.i b/python/numpy.i new file mode 100644 index 0000000..36bb55c --- /dev/null +++ b/python/numpy.i @@ -0,0 +1,3183 @@ +/* -*- C -*- (not really, but good for syntax highlighting) */ + +/* + * Copyright (c) 2005-2015, NumPy Developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of the NumPy Developers nor the names of any + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef SWIGPYTHON + +%{ +#ifndef SWIG_FILE_WITH_INIT +#define NO_IMPORT_ARRAY +#endif +#include "stdio.h" +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include +%} + +/**********************************************************************/ + +%fragment("NumPy_Backward_Compatibility", "header") +{ +%#if NPY_API_VERSION < 0x00000007 +%#define NPY_ARRAY_DEFAULT NPY_DEFAULT +%#define NPY_ARRAY_FARRAY NPY_FARRAY +%#define NPY_FORTRANORDER NPY_FORTRAN +%#endif +} + +/**********************************************************************/ + +/* The following code originally appeared in + * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was + * translated from C++ to C by John Hunter. Bill Spotz has modified + * it to fix some minor bugs, upgrade from Numeric to numpy (all + * versions), add some comments and functionality, and convert from + * direct code insertion to SWIG fragments. + */ + +%fragment("NumPy_Macros", "header") +{ +/* Macros to extract array attributes. + */ +%#if NPY_API_VERSION < 0x00000007 +%#define is_array(a) ((a) && PyArray_Check((PyArrayObject*)a)) +%#define array_type(a) (int)(PyArray_TYPE((PyArrayObject*)a)) +%#define array_numdims(a) (((PyArrayObject*)a)->nd) +%#define array_dimensions(a) (((PyArrayObject*)a)->dimensions) +%#define array_size(a,i) (((PyArrayObject*)a)->dimensions[i]) +%#define array_strides(a) (((PyArrayObject*)a)->strides) +%#define array_stride(a,i) (((PyArrayObject*)a)->strides[i]) +%#define array_data(a) (((PyArrayObject*)a)->data) +%#define array_descr(a) (((PyArrayObject*)a)->descr) +%#define array_flags(a) (((PyArrayObject*)a)->flags) +%#define array_clearflags(a,f) (((PyArrayObject*)a)->flags) &= ~f +%#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f +%#define array_is_fortran(a) (PyArray_ISFORTRAN((PyArrayObject*)a)) +%#else +%#define is_array(a) ((a) && PyArray_Check(a)) +%#define array_type(a) PyArray_TYPE((PyArrayObject*)a) +%#define array_numdims(a) PyArray_NDIM((PyArrayObject*)a) +%#define array_dimensions(a) PyArray_DIMS((PyArrayObject*)a) +%#define array_strides(a) PyArray_STRIDES((PyArrayObject*)a) +%#define array_stride(a,i) PyArray_STRIDE((PyArrayObject*)a,i) +%#define array_size(a,i) PyArray_DIM((PyArrayObject*)a,i) +%#define array_data(a) PyArray_DATA((PyArrayObject*)a) +%#define array_descr(a) PyArray_DESCR((PyArrayObject*)a) +%#define array_flags(a) PyArray_FLAGS((PyArrayObject*)a) +%#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f) +%#define array_clearflags(a,f) PyArray_CLEARFLAGS((PyArrayObject*)a,f) +%#define array_is_fortran(a) (PyArray_IS_F_CONTIGUOUS((PyArrayObject*)a)) +%#endif +%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a)) +%#define array_is_native(a) (PyArray_ISNOTSWAPPED((PyArrayObject*)a)) +} + +/**********************************************************************/ + +%fragment("NumPy_Utilities", + "header") +{ + /* Given a PyObject, return a string describing its type. + */ + const char* pytype_string(PyObject* py_obj) + { + if (py_obj == NULL ) return "C NULL value"; + if (py_obj == Py_None ) return "Python None" ; + if (PyCallable_Check(py_obj)) return "callable" ; + if (PyString_Check( py_obj)) return "string" ; + if (PyInt_Check( py_obj)) return "int" ; + if (PyFloat_Check( py_obj)) return "float" ; + if (PyDict_Check( py_obj)) return "dict" ; + if (PyList_Check( py_obj)) return "list" ; + if (PyTuple_Check( py_obj)) return "tuple" ; +%#if PY_MAJOR_VERSION < 3 + if (PyFile_Check( py_obj)) return "file" ; + if (PyModule_Check( py_obj)) return "module" ; + if (PyInstance_Check(py_obj)) return "instance" ; +%#endif + + return "unknown type"; + } + + /* Given a NumPy typecode, return a string describing the type. + */ + const char* typecode_string(int typecode) + { + static const char* type_names[25] = {"bool", + "byte", + "unsigned byte", + "short", + "unsigned short", + "int", + "unsigned int", + "long", + "unsigned long", + "long long", + "unsigned long long", + "float", + "double", + "long double", + "complex float", + "complex double", + "complex long double", + "object", + "string", + "unicode", + "void", + "ntypes", + "notype", + "char", + "unknown"}; + return typecode < 24 ? type_names[typecode] : type_names[24]; + } + + /* Make sure input has correct numpy type. This now just calls + PyArray_EquivTypenums(). + */ + int type_match(int actual_type, + int desired_type) + { + return PyArray_EquivTypenums(actual_type, desired_type); + } + +%#ifdef SWIGPY_USE_CAPSULE + void free_cap(PyObject * cap) + { + void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME); + if (array != NULL) free(array); + } +%#endif + + +} + +/**********************************************************************/ + +%fragment("NumPy_Object_to_Array", + "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros", + fragment="NumPy_Utilities") +{ + /* Given a PyObject pointer, cast it to a PyArrayObject pointer if + * legal. If not, set the python error string appropriately and + * return NULL. + */ + PyArrayObject* obj_to_array_no_conversion(PyObject* input, + int typecode) + { + PyArrayObject* ary = NULL; + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input), typecode))) + { + ary = (PyArrayObject*) input; + } + else if is_array(input) + { + const char* desired_type = typecode_string(typecode); + const char* actual_type = typecode_string(array_type(input)); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. Array of type '%s' given", + desired_type, actual_type); + ary = NULL; + } + else + { + const char* desired_type = typecode_string(typecode); + const char* actual_type = pytype_string(input); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. A '%s' was given", + desired_type, + actual_type); + ary = NULL; + } + return ary; + } + + /* Convert the given PyObject to a NumPy array with the given + * typecode. On success, return a valid PyArrayObject* with the + * correct type. On failure, the python error string will be set and + * the routine returns NULL. + */ + PyArrayObject* obj_to_array_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + PyArrayObject* ary = NULL; + PyObject* py_obj; + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input),typecode))) + { + ary = (PyArrayObject*) input; + *is_new_object = 0; + } + else + { + py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_ARRAY_DEFAULT); + /* If NULL, PyArray_FromObject will have set python error value.*/ + ary = (PyArrayObject*) py_obj; + *is_new_object = 1; + } + return ary; + } + + /* Given a PyArrayObject, check to see if it is contiguous. If so, + * return the input pointer and flag it as not a new object. If it is + * not contiguous, create a new PyArrayObject using the original data, + * flag it as a new object and return the pointer. + */ + PyArrayObject* make_contiguous(PyArrayObject* ary, + int* is_new_object, + int min_dims, + int max_dims) + { + PyArrayObject* result; + if (array_is_contiguous(ary)) + { + result = ary; + *is_new_object = 0; + } + else + { + result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary, + array_type(ary), + min_dims, + max_dims); + *is_new_object = 1; + } + return result; + } + + /* Given a PyArrayObject, check to see if it is Fortran-contiguous. + * If so, return the input pointer, but do not flag it as not a new + * object. If it is not Fortran-contiguous, create a new + * PyArrayObject using the original data, flag it as a new object + * and return the pointer. + */ + PyArrayObject* make_fortran(PyArrayObject* ary, + int* is_new_object) + { + PyArrayObject* result; + if (array_is_fortran(ary)) + { + result = ary; + *is_new_object = 0; + } + else + { + Py_INCREF(array_descr(ary)); + result = (PyArrayObject*) PyArray_FromArray(ary, + array_descr(ary), +%#if NPY_API_VERSION < 0x00000007 + NPY_FORTRANORDER); +%#else + NPY_ARRAY_F_CONTIGUOUS); +%#endif + *is_new_object = 1; + } + return result; + } + + /* Convert a given PyObject to a contiguous PyArrayObject of the + * specified type. If the input object is not a contiguous + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ + PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, + typecode, + &is_new1); + if (ary1) + { + ary2 = make_contiguous(ary1, &is_new2, 0, 0); + if ( is_new1 && is_new2) + { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; + } + + /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the + * specified type. If the input object is not a Fortran-ordered + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ + PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, + typecode, + &is_new1); + if (ary1) + { + ary2 = make_fortran(ary1, &is_new2); + if (is_new1 && is_new2) + { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; + } +} /* end fragment */ + +/**********************************************************************/ + +%fragment("NumPy_Array_Requirements", + "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros") +{ + /* Test whether a python object is contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ + int require_contiguous(PyArrayObject* ary) + { + int contiguous = 1; + if (!array_is_contiguous(ary)) + { + PyErr_SetString(PyExc_TypeError, + "Array must be contiguous. A non-contiguous array was given"); + contiguous = 0; + } + return contiguous; + } + + /* Test whether a python object is (C_ or F_) contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ + int require_c_or_f_contiguous(PyArrayObject* ary) + { + int contiguous = 1; + if (!(array_is_contiguous(ary) || array_is_fortran(ary))) + { + PyErr_SetString(PyExc_TypeError, + "Array must be contiguous (C_ or F_). A non-contiguous array was given"); + contiguous = 0; + } + return contiguous; + } + + /* Require that a numpy array is not byte-swapped. If the array is + * not byte-swapped, return 1. Otherwise, set the python error string + * and return 0. + */ + int require_native(PyArrayObject* ary) + { + int native = 1; + if (!array_is_native(ary)) + { + PyErr_SetString(PyExc_TypeError, + "Array must have native byteorder. " + "A byte-swapped array was given"); + native = 0; + } + return native; + } + + /* Require the given PyArrayObject to have a specified number of + * dimensions. If the array has the specified number of dimensions, + * return 1. Otherwise, set the python error string and return 0. + */ + int require_dimensions(PyArrayObject* ary, + int exact_dimensions) + { + int success = 1; + if (array_numdims(ary) != exact_dimensions) + { + PyErr_Format(PyExc_TypeError, + "Array must have %d dimensions. Given array has %d dimensions", + exact_dimensions, + array_numdims(ary)); + success = 0; + } + return success; + } + + /* Require the given PyArrayObject to have one of a list of specified + * number of dimensions. If the array has one of the specified number + * of dimensions, return 1. Otherwise, set the python error string + * and return 0. + */ + int require_dimensions_n(PyArrayObject* ary, + int* exact_dimensions, + int n) + { + int success = 0; + int i; + char dims_str[255] = ""; + char s[255]; + for (i = 0; i < n && !success; i++) + { + if (array_numdims(ary) == exact_dimensions[i]) + { + success = 1; + } + } + if (!success) + { + for (i = 0; i < n-1; i++) + { + sprintf(s, "%d, ", exact_dimensions[i]); + strcat(dims_str,s); + } + sprintf(s, " or %d", exact_dimensions[n-1]); + strcat(dims_str,s); + PyErr_Format(PyExc_TypeError, + "Array must have %s dimensions. Given array has %d dimensions", + dims_str, + array_numdims(ary)); + } + return success; + } + + /* Require the given PyArrayObject to have a specified shape. If the + * array has the specified shape, return 1. Otherwise, set the python + * error string and return 0. + */ + int require_size(PyArrayObject* ary, + npy_intp* size, + int n) + { + int i; + int success = 1; + size_t len; + char desired_dims[255] = "["; + char s[255]; + char actual_dims[255] = "["; + for(i=0; i < n;i++) + { + if (size[i] != -1 && size[i] != array_size(ary,i)) + { + success = 0; + } + } + if (!success) + { + for (i = 0; i < n; i++) + { + if (size[i] == -1) + { + sprintf(s, "*,"); + } + else + { + sprintf(s, "%ld,", (long int)size[i]); + } + strcat(desired_dims,s); + } + len = strlen(desired_dims); + desired_dims[len-1] = ']'; + for (i = 0; i < n; i++) + { + sprintf(s, "%ld,", (long int)array_size(ary,i)); + strcat(actual_dims,s); + } + len = strlen(actual_dims); + actual_dims[len-1] = ']'; + PyErr_Format(PyExc_TypeError, + "Array must have shape of %s. Given array has shape of %s", + desired_dims, + actual_dims); + } + return success; + } + + /* Require the given PyArrayObject to to be Fortran ordered. If the + * the PyArrayObject is already Fortran ordered, do nothing. Else, + * set the Fortran ordering flag and recompute the strides. + */ + int require_fortran(PyArrayObject* ary) + { + int success = 1; + int nd = array_numdims(ary); + int i; + npy_intp * strides = array_strides(ary); + if (array_is_fortran(ary)) return success; + int n_non_one = 0; + /* Set the Fortran ordered flag */ + const npy_intp *dims = array_dimensions(ary); + for (i=0; i < nd; ++i) + n_non_one += (dims[i] != 1) ? 1 : 0; + if (n_non_one > 1) + array_clearflags(ary,NPY_ARRAY_CARRAY); + array_enableflags(ary,NPY_ARRAY_FARRAY); + /* Recompute the strides */ + strides[0] = strides[nd-1]; + for (i=1; i < nd; ++i) + strides[i] = strides[i-1] * array_size(ary,i-1); + return success; + } +} + +/* Combine all NumPy fragments into one for convenience */ +%fragment("NumPy_Fragments", + "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros", + fragment="NumPy_Utilities", + fragment="NumPy_Object_to_Array", + fragment="NumPy_Array_Requirements") +{ +} + +/* End John Hunter translation (with modifications by Bill Spotz) + */ + +/* %numpy_typemaps() macro + * + * This macro defines a family of 75 typemaps that allow C arguments + * of the form + * + * 1. (DATA_TYPE IN_ARRAY1[ANY]) + * 2. (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + * 3. (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + * + * 4. (DATA_TYPE IN_ARRAY2[ANY][ANY]) + * 5. (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 6. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + * 7. (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 8. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + * + * 9. (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + * 10. (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 11. (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 12. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) + * 13. (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 14. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) + * + * 15. (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) + * 16. (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 17. (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 18. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) + * 19. (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 20. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) + * + * 21. (DATA_TYPE INPLACE_ARRAY1[ANY]) + * 22. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + * 23. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + * + * 24. (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + * 25. (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 26. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + * 27. (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * 28. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + * + * 29. (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + * 30. (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 31. (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 32. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) + * 33. (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * 34. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) + * + * 35. (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) + * 36. (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 37. (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 38. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4) + * 39. (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + * 40. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4) + * + * 41. (DATA_TYPE ARGOUT_ARRAY1[ANY]) + * 42. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + * 43. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + * + * 44. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + * + * 45. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + * + * 46. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) + * + * 47. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) + * 48. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) + * + * 49. (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 50. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) + * 51. (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 52. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) + * + * 53. (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 54. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) + * 55. (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 56. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) + * + * 57. (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 58. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4) + * 59. (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 60. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4) + * + * 61. (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1) + * 62. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1) + * + * 63. (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 64. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2) + * 65. (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * 66. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2) + * + * 67. (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 68. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3) + * 69. (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * 70. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3) + * + * 71. (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 72. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) + * 73. (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) + * 74. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) + * + * 75. (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) + * + * where "DATA_TYPE" is any type supported by the NumPy module, and + * "DIM_TYPE" is any int-like type suitable for specifying dimensions. + * The difference between "ARRAY" typemaps and "FARRAY" typemaps is + * that the "FARRAY" typemaps expect Fortran ordering of + * multidimensional arrays. In python, the dimensions will not need + * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1" + * typemaps). The IN_ARRAYs can be a numpy array or any sequence that + * can be converted to a numpy array of the specified type. The + * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The + * ARGOUT_ARRAYs will be returned as new numpy arrays of the + * appropriate type. + * + * These typemaps can be applied to existing functions using the + * %apply directive. For example: + * + * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)}; + * double prod(double* series, int length); + * + * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2) + * {(int rows, int cols, double* matrix )}; + * void floor(int rows, int cols, double* matrix, double f); + * + * %apply (double IN_ARRAY3[ANY][ANY][ANY]) + * {(double tensor[2][2][2] )}; + * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY]) + * {(double low[2][2][2] )}; + * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY]) + * {(double upp[2][2][2] )}; + * void luSplit(double tensor[2][2][2], + * double low[2][2][2], + * double upp[2][2][2] ); + * + * or directly with + * + * double prod(double* IN_ARRAY1, int DIM1); + * + * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f); + * + * void luSplit(double IN_ARRAY3[ANY][ANY][ANY], + * double ARGOUT_ARRAY3[ANY][ANY][ANY], + * double ARGOUT_ARRAY3[ANY][ANY][ANY]); + */ + +%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE) + +/************************/ +/* Input Array Typemaps */ +/************************/ + +/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY1[ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY1[ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = { $1_dim0 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY1[ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = { -1 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = {-1}; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY2[ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY2[ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { $1_dim0, $1_dim1 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY2[ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = obj_to_array_contiguous_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + /* for now, only concerned with lists */ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL) +{ + npy_intp size[2] = { -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + int is_new_object; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + is_new_object_array = (int *)calloc($2,sizeof(int)); + + if (array == NULL || object_array == NULL || is_new_object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + is_new_object_array[i] = is_new_object; + + if (!temp_array || !require_dimensions(temp_array, 2)) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + } + + if (!require_size(temp_array, size, 2)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; +} +%typemap(freearg) + (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + Py_ssize_t i; + + if (array$argnum!=NULL) free(array$argnum); + + /*freeing the individual arrays if needed */ + if (object_array$argnum!=NULL) + { + if (is_new_object_array$argnum!=NULL) + { + for (i=0; i<$2; i++) + { + if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i]) + { Py_DECREF(object_array$argnum[i]); } + } + free(is_new_object_array$argnum); + } + free(object_array$argnum); + } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* IN_ARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* IN_FARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, + DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3}; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + /* for now, only concerned with lists */ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL) +{ + npy_intp size[3] = { -1, -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + int is_new_object; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + is_new_object_array = (int *)calloc($2,sizeof(int)); + + if (array == NULL || object_array == NULL || is_new_object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + is_new_object_array[i] = is_new_object; + + if (!temp_array || !require_dimensions(temp_array, 3)) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + size[2] = array_size(temp_array,2); + } + + if (!require_size(temp_array, size, 3)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; + $5 = (DIM_TYPE) size[2]; +} +%typemap(freearg) + (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + Py_ssize_t i; + + if (array$argnum!=NULL) free(array$argnum); + + /*freeing the individual arrays if needed */ + if (object_array$argnum!=NULL) + { + if (is_new_object_array$argnum!=NULL) + { + for (i=0; i<$2; i++) + { + if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i]) + { Py_DECREF(object_array$argnum[i]); } + } + free(is_new_object_array$argnum); + } + free(object_array$argnum); + } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, + * DATA_TYPE* IN_ARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1 , -1}; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4) | !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, + * DATA_TYPE* IN_FARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[4] = { -1, -1, -1 , -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 4) || + !require_size(array, size, 4) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/***************************/ +/* In-Place Array Typemaps */ +/***************************/ + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY1[ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY1[ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[1] = { $1_dim0 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + (PyArrayObject* array=NULL, int i=1) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = 1; + for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i); +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + (PyArrayObject* array=NULL, int i=0) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = 1; + for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i); + $2 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[2] = { $1_dim0, $1_dim1 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} + +/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL) +{ + npy_intp size[2] = { -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + + if (array == NULL || object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + + if ( !temp_array || !require_dimensions(temp_array, 2) || + !require_contiguous(temp_array) || + !require_native(temp_array) || + !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE) + ) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + } + + if (!require_size(temp_array, size, 2)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; +} +%typemap(freearg) + (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (array$argnum!=NULL) free(array$argnum); + if (object_array$argnum!=NULL) free(object_array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_ARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_FARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_size(array, size, 4) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} + +/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL) +{ + npy_intp size[3] = { -1, -1, -1 }; + PyArrayObject* temp_array; + Py_ssize_t i; + + /* length of the list */ + $2 = PyList_Size($input); + + /* the arrays */ + array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *)); + object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *)); + + if (array == NULL || object_array == NULL) + { + SWIG_fail; + } + + for (i=0; i<$2; i++) + { + temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE); + + /* the new array must be stored so that it can be destroyed in freearg */ + object_array[i] = temp_array; + + if ( !temp_array || !require_dimensions(temp_array, 3) || + !require_contiguous(temp_array) || + !require_native(temp_array) || + !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE) + ) SWIG_fail; + + /* store the size of the first array in the list, then use that for comparison. */ + if (i == 0) + { + size[0] = array_size(temp_array,0); + size[1] = array_size(temp_array,1); + size[2] = array_size(temp_array,2); + } + + if (!require_size(temp_array, size, 3)) SWIG_fail; + + array[i] = (DATA_TYPE*) array_data(temp_array); + } + + $1 = (DATA_TYPE**) array; + $3 = (DIM_TYPE) size[0]; + $4 = (DIM_TYPE) size[1]; + $5 = (DIM_TYPE) size[2]; +} +%typemap(freearg) + (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + if (array$argnum!=NULL) free(array$argnum); + if (object_array$argnum!=NULL) free(object_array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, + * DATA_TYPE* INPLACE_ARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3, DIM_TYPE DIM4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); + $5 = (DIM_TYPE) array_size(array,3); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_FARRAY4) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,4) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DIM_TYPE) array_size(array,3); + $5 = (DATA_TYPE*) array_data(array); +} + +/*************************/ +/* Argout Array Typemaps */ +/*************************/ + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY1[ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[1] = { $1_dim0 }; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY1[ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + */ +%typemap(in,numinputs=1, + fragment="NumPy_Fragments") + (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + (PyObject* array = NULL) +{ + npy_intp dims[1]; + if (!PyInt_Check($input)) + { + const char* typestring = pytype_string($input); + PyErr_Format(PyExc_TypeError, + "Int dimension expected. '%s' given.", + typestring); + SWIG_fail; + } + $2 = (DIM_TYPE) PyInt_AsLong($input); + dims[0] = (npy_intp) $2; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); +} +%typemap(argout) + (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + */ +%typemap(in,numinputs=1, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + (PyObject* array = NULL) +{ + npy_intp dims[1]; + if (!PyInt_Check($input)) + { + const char* typestring = pytype_string($input); + PyErr_Format(PyExc_TypeError, + "Int dimension expected. '%s' given.", + typestring); + SWIG_fail; + } + $1 = (DIM_TYPE) PyInt_AsLong($input); + dims[0] = (npy_intp) $1; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $2 = (DATA_TYPE*) array_data(array); +} +%typemap(argout) + (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[2] = { $1_dim0, $1_dim1 }; + array = PyArray_SimpleNew(2, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = PyArray_SimpleNew(3, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) + (PyObject* array = NULL) +{ + npy_intp dims[4] = { $1_dim0, $1_dim1, $1_dim2, $1_dim3 }; + array = PyArray_SimpleNew(4, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum); +} + +/*****************************/ +/* Argoutview Array Typemaps */ +/*****************************/ + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp) +{ + $1 = &data_temp; + $2 = &dim_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) +{ + npy_intp dims[1] = { *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1) + (DIM_TYPE dim_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim_temp; + $2 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) +{ + npy_intp dims[1] = { *$1 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEW_ARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEW_FARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEW_FARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEW_ARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEW_ARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEW_FARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEW_FARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/*************************************/ +/* Managed Argoutview Array Typemaps */ +/*************************************/ + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp) +{ + $1 = &data_temp; + $2 = &dim_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1) +{ + npy_intp dims[1] = { *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEWM_ARRAY1) + (DIM_TYPE dim_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim_temp; + $2 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1) +{ + npy_intp dims[1] = { *$1 }; + PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEWM_ARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEWM_FARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEWM_ARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEWM_ARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj= PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEWM_FARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEWM_FARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_ARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_ARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_FARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_FARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_ARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_ARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3, DIM_TYPE* DIM4) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) + (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; + $5 = &dim4_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) +{ + npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, + DATA_TYPE** ARGOUTVIEWM_FARRAY4) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_FARRAY4) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &dim4_temp; + $5 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) +{ + npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; + PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); + PyArrayObject* array = (PyArrayObject*) obj; + + if (!array || !require_fortran(array)) SWIG_fail; + +%#ifdef SWIGPY_USE_CAPSULE + PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); +%#else + PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); +%#endif + +%#if NPY_API_VERSION < 0x00000007 + PyArray_BASE(array) = cap; +%#else + PyArray_SetBaseObject(array,cap); +%#endif + + $result = SWIG_Python_AppendOutput($result,obj); +} + +/**************************************/ +/* In-Place Array Typemap - flattened */ +/**************************************/ + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT) + (PyArrayObject* array=NULL, int i=1) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_c_or_f_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = 1; + for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i); +} + +%enddef /* %numpy_typemaps() macro */ +/* *************************************************************** */ + +/* Concrete instances of the %numpy_typemaps() macro: Each invocation + * below applies all of the typemaps above to the specified data type. + */ +%numpy_typemaps(signed char , NPY_BYTE , int) +%numpy_typemaps(unsigned char , NPY_UBYTE , int) +%numpy_typemaps(short , NPY_SHORT , int) +%numpy_typemaps(unsigned short , NPY_USHORT , int) +%numpy_typemaps(int , NPY_INT , int) +%numpy_typemaps(unsigned int , NPY_UINT , int) +%numpy_typemaps(long , NPY_LONG , int) +%numpy_typemaps(unsigned long , NPY_ULONG , int) +%numpy_typemaps(long long , NPY_LONGLONG , int) +%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int) +%numpy_typemaps(float , NPY_FLOAT , int) +%numpy_typemaps(double , NPY_DOUBLE , int) +%numpy_typemaps(int8_t , NPY_INT8 , int) +%numpy_typemaps(int16_t , NPY_INT16 , int) +%numpy_typemaps(int32_t , NPY_INT32 , int) +%numpy_typemaps(int64_t , NPY_INT64 , int) +%numpy_typemaps(uint8_t , NPY_UINT8 , int) +%numpy_typemaps(uint16_t , NPY_UINT16 , int) +%numpy_typemaps(uint32_t , NPY_UINT32 , int) +%numpy_typemaps(uint64_t , NPY_UINT64 , int) + + +/* *************************************************************** + * The follow macro expansion does not work, because C++ bool is 4 + * bytes and NPY_BOOL is 1 byte + * + * %numpy_typemaps(bool, NPY_BOOL, int) + */ + +/* *************************************************************** + * On my Mac, I get the following warning for this macro expansion: + * 'swig/python detected a memory leak of type 'long double *', no destructor found.' + * + * %numpy_typemaps(long double, NPY_LONGDOUBLE, int) + */ + +#ifdef __cplusplus + +%include + +%numpy_typemaps(std::complex, NPY_CFLOAT , int) +%numpy_typemaps(std::complex, NPY_CDOUBLE, int) + +#endif + +#endif /* SWIGPYTHON */ diff --git a/python/pyqmckl.i b/python/pyqmckl.i new file mode 100644 index 0000000..3f68b0f --- /dev/null +++ b/python/pyqmckl.i @@ -0,0 +1,52 @@ +%module pyqmckl +/* Define SWIGWORDSIZE in order to properly align long integers on 64-bit system */ +#define SWIGWORDSIZE64 +%{ +#define SWIG_FILE_WITH_INIT +/* Include the headers in the wrapper code */ +#include "qmckl.h" +%} + + +/* Include stdint to recognize types from stdint.h */ +%include + + +/* Include typemaps to play with input/output re-casting + Useful when working with C pointers +*/ +%include typemaps.i + +/* Return TREXIO exit code from trexio_open as part of the output tuple */ +%apply int *OUTPUT { qmckl_exit_code *exit_code}; + +/* This enables access to trexio_[...]_read_dset_str_low set of functions + in order to return one long string with TREXIO_DELIM delimeter as 2-nd argument of output tuple + */ +%include + + +/* This block is needed make SWIG treat (double * dset_out|_in, int64_t dim_out|_in) pattern + as a special case in order to return the NumPy array to Python from C pointer to array + provided by trexio_read_safe_[dset_num] function. + NOTE: numpy.i is currently not part of SWIG but included in the numpy distribution (under numpy/tools/swig/numpy.i) +*/ +%include "numpy.i" + +%init %{ +import_array(); +%} + +/* Typemaps below change the type of numpy array dimensions from int to int64_t */ +%numpy_typemaps(double, NPY_DOUBLE, int64_t) +%numpy_typemaps(float, NPY_FLOAT, int64_t) +%numpy_typemaps(int32_t, NPY_INT32, int64_t) +%numpy_typemaps(int64_t, NPY_INT64, int64_t) + +/* Include typemaps generated by the process.py */ +%include pyqmckl_include.i + + +/* Parse the header files to generate wrappers */ +%include "qmckl.h" + diff --git a/python/pyqmckl_include.i b/python/pyqmckl_include.i new file mode 100644 index 0000000..beafb48 --- /dev/null +++ b/python/pyqmckl_include.i @@ -0,0 +1,96 @@ +%apply int *OUTPUT { int64_t* const num }; +%apply int *OUTPUT { int64_t* const num }; +%apply float *OUTPUT { double* const rescale_factor_kappa }; +%apply float *OUTPUT { double* const energy }; +%apply int *OUTPUT { int64_t* const num }; +%apply int *OUTPUT { int64_t* const up_num }; +%apply int *OUTPUT { int64_t* const down_num }; +%apply int *OUTPUT { int64_t* const walk_num }; +%apply float *OUTPUT { double* const rescale_factor_kappa_ee }; +%apply float *OUTPUT { double* const rescale_factor_kappa_en }; +%apply float *OUTPUT { double* const distance }; +%apply float *OUTPUT { double* const distance_rescaled }; +%apply float *OUTPUT { double* const distance_rescaled_deriv_e }; +%apply float *OUTPUT { double* const ee_pot }; +%apply float *OUTPUT { double* distance }; +%apply float *OUTPUT { double* distance_rescaled }; +%apply float *OUTPUT { double* distance_rescaled_deriv_e }; +%apply float *OUTPUT { double* const en_pot }; +%apply int *OUTPUT { int64_t* const shell_num }; +%apply int *OUTPUT { int64_t* const prim_num }; +%apply int *OUTPUT { int64_t* const ao_num }; +%apply int *OUTPUT { int64_t* mo_num }; +%apply float *OUTPUT { double* const mo_vgl }; +%apply float *OUTPUT { double* const det_vgl_alpha }; +%apply float *OUTPUT { double* const det_vgl_beta }; +%apply float *OUTPUT { double* const det_inv_matrix_alpha }; +%apply float *OUTPUT { double* const det_inv_matrix_beta }; +%apply float *OUTPUT { double* const det_adj_matrix_alpha }; +%apply float *OUTPUT { double* const det_adj_matrix_beta }; +%apply float *OUTPUT { double* const det_adj_matrix_alpha }; +%apply float *OUTPUT { double* const det_adj_matrix_beta }; +%apply int *OUTPUT { int64_t* const aord_num }; +%apply int *OUTPUT { int64_t* const bord_num }; +%apply int *OUTPUT { int64_t* const bord_num }; +%apply int *OUTPUT { int64_t* const type_nucl_num }; +%apply int *OUTPUT { int64_t* const dim_cord_vect }; +%apply float *OUTPUT { double* const cord_vect_full }; +%apply int *OUTPUT { int64_t* const lkpm_combined_index }; +%apply float *OUTPUT { double* const tmp_c }; +%apply float *OUTPUT { double* const dtmp_c }; +%apply float *OUTPUT { double* const kinetic_energy }; +%apply float *OUTPUT { double* const potential_energy }; +%apply float *OUTPUT { double* const local_energy }; +%apply float *OUTPUT { double* const drift_vector }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const coord,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const charge,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const coord,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* charge,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* coord,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* distance,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* distance_rescaled,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const coord,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { ( const double* coord , const int64_t size_max) }; +%apply ( int64_t* IN_ARRAY1 , int64_t DIM1 ) { (const int64_t* nucleus_index,const int64_t size_max) }; +%apply ( int64_t* IN_ARRAY1 , int64_t DIM1 ) { (const int64_t* nucleus_shell_num,const int64_t size_max) }; +%apply ( int32_t* IN_ARRAY1 , int64_t DIM1 ) { (const int32_t* shell_ang_mom,const int64_t size_max) }; +%apply ( int64_t* IN_ARRAY1 , int64_t DIM1 ) { (const int64_t* shell_prim_num,const int64_t size_max) }; +%apply ( int64_t* IN_ARRAY1 , int64_t DIM1 ) { (const int64_t* shell_prim_index,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* shell_factor,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* exponent,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* coefficient,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* prim_factor,const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { (const double* ao_factor,const int64_t size_max) }; +%apply ( int64_t* ARGOUT_ARRAY1 , int64_t DIM1 ) { (int64_t* const nucleus_shell_num,const int64_t size_max) }; +%apply ( int64_t* ARGOUT_ARRAY1 , int64_t DIM1 ) { (int64_t* const nucleus_index,const int64_t size_max) }; +%apply ( int32_t* ARGOUT_ARRAY1 , int64_t DIM1 ) { (int32_t* const shell_ang_mom,const int64_t size_max) }; +%apply ( int64_t* ARGOUT_ARRAY1 , int64_t DIM1 ) { (int64_t* const shell_prim_num,const int64_t size_max) }; +%apply ( int64_t* ARGOUT_ARRAY1 , int64_t DIM1 ) { (int64_t* const shell_prim_index,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const shell_factor,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const exponent,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const coefficient,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const prim_factor,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const ao_factor,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const primitive_vgl,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const shell_vgl,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const ao_vgl,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const ao_vgl,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const coefficient,const int64_t size_max) }; +%apply ( int64_t* ARGOUT_ARRAY1 , int64_t DIM1 ) { ( int64_t* const type_nucl_num , const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { ( double * const aord_vector , const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { ( double * const bord_vector , const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { ( double * const cord_vector , const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { ( const double * aord_vector , const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { ( const double * bord_vector , const int64_t size_max) }; +%apply ( double* IN_ARRAY1 , int64_t DIM1 ) { ( const double * cord_vector , const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const asymp_jasb,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const factor_ee,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const factor_ee_deriv_e,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const factor_en,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const factor_en_deriv_e,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const distance_rescaled,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const distance_rescaled,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const distance_rescaled,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const distance_rescaled,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const factor_een,const int64_t size_max) }; +%apply ( double* ARGOUT_ARRAY1 , int64_t DIM1 ) { (double* const factor_een_deriv_e,const int64_t size_max) }; diff --git a/python/pytrexio.i b/python/pytrexio.i new file mode 100644 index 0000000..121d465 --- /dev/null +++ b/python/pytrexio.i @@ -0,0 +1,141 @@ +%module pytrexio +/* Define SWIGWORDSIZE in order to properly align long integers on 64-bit system */ +#define SWIGWORDSIZE64 +%{ +#define SWIG_FILE_WITH_INIT +/* Include the headers in the wrapper code */ +#include "trexio_s.h" +#include "trexio.h" +%} + +/* Include stdint to recognize types from stdint.h */ +%include + +/* NOTE: + carrays was useful before numpy.i was introduced. + For Python interface it's better to use numpy arrays instead of carrays, because the latter are less python-ic. + On the other hand, carrays might be more portable to other target languages. +// Include carrays to work with C pointers to arrays +%include "carrays.i" +// Include classes that correspond to integer and float arrays +%array_class(double, doubleArray); +%array_class(float, floatArray); +%array_class(int32_t, int32Array); +%array_class(int64_t, int64Array); +*/ + +/* Include typemaps to play with input/output re-casting + Useful when working with C pointers +*/ +%include typemaps.i +/* Redefine the [int32_t*, int64_t*, float*, double*] num + pattern to be appended to the output tuple. + Useful for TREXIO read_num functions where the + num variable is modified by address +*/ +/* Return num variables as part of the output tuple */ +%apply int *OUTPUT { int32_t* const num}; +%apply int *OUTPUT { int64_t* const num}; +%apply int *OUTPUT { int32_t* const num_up}; +%apply int *OUTPUT { int32_t* const num_dn}; +%apply int *OUTPUT { int64_t* const num_up}; +%apply int *OUTPUT { int64_t* const num_dn}; +%apply float *OUTPUT { float* const num}; +%apply float *OUTPUT { double* const num}; +/* Return TREXIO exit code from trexio_open as part of the output tuple */ +%apply int *OUTPUT { trexio_exit_code* const rc_open}; +/* Return number of sparse data points stored in the file as part of the output tuple */ +%apply int *OUTPUT { int64_t* const size_max}; +/* Return number of sparse data points read from the file as part of the output tuple */ +%apply int *INOUT { int64_t* const buffer_size_read}; + +/* Does not work for arrays (SIGSEGV) */ + +/* This enables access to trexio_[...]_read_dset_str_low set of functions + in order to return one long string with TREXIO_DELIM delimeter as 2-nd argument of output tuple + */ +%include +/* This enables read of long strings with TREXIO_DELIM delimeters that can be further converted into an array of string */ +%cstring_bounded_output(char* dset_out, 4096); +/* This enables read of single string attributes with pre-defined max_str_len + for Python we pre-define max_str_len = PYTREXIO_MAX_STR_LENGTH everywhere for simplicity +*/ +%cstring_output_maxsize(char* const str_out, const int32_t max_str_len); + + +/* This block is needed make SWIG treat (double * dset_out|_in, int64_t dim_out|_in) pattern + as a special case in order to return the NumPy array to Python from C pointer to array + provided by trexio_read_safe_[dset_num] function. + NOTE: numpy.i is currently not part of SWIG but included in the numpy distribution (under numpy/tools/swig/numpy.i) +*/ +%include "numpy.i" + +%init %{ +import_array(); +%} + +/* Typemaps below change the type of numpy array dimensions from int to int64_t */ +%numpy_typemaps(double, NPY_DOUBLE, int64_t) +%numpy_typemaps(float, NPY_FLOAT, int64_t) +%numpy_typemaps(int32_t, NPY_INT32, int64_t) +%numpy_typemaps(int64_t, NPY_INT64, int64_t) +%numpy_typemaps(bitfield_t, NPY_INT64, int64_t) +/* Enable write|read_safe functions to convert numpy arrays from/to double arrays */ +%apply (double* ARGOUT_ARRAY1, int64_t DIM1) {(double* const dset_out, const int64_t dim_out)}; +%apply (double* IN_ARRAY1, int64_t DIM1) {(const double* dset_in, const int64_t dim_in)}; +/* Enable write|read_safe functions to convert numpy arrays from/to float arrays */ +%apply (float* ARGOUT_ARRAY1, int64_t DIM1) {(float* const dset_out, const int64_t dim_out)}; +%apply (float* IN_ARRAY1, int64_t DIM1) {(const float* dset_in, const int64_t dim_in)}; +/* Enable write|read_safe functions to convert numpy arrays from/to int32 arrays */ +%apply (int32_t* ARGOUT_ARRAY1, int64_t DIM1) {(int32_t* const dset_out, const int64_t dim_out)}; +%apply (int32_t* IN_ARRAY1, int64_t DIM1) {(const int32_t* dset_in, const int64_t dim_in)}; +/* Enable write|read_safe functions to convert numpy arrays from/to int64 arrays */ +%apply (int64_t* ARGOUT_ARRAY1, int64_t DIM1) {(int64_t* const dset_out, const int64_t dim_out)}; +%apply (int64_t* IN_ARRAY1, int64_t DIM1) {(const int64_t* dset_in, const int64_t dim_in)}; +/* Enable write|read_safe functions to convert numpy arrays from/to sparse arrays */ +%apply (double* IN_ARRAY1, int64_t DIM1) {(const double* value_sparse_write, const int64_t size_value_write)}; +%apply (int32_t* IN_ARRAY1, int64_t DIM1) {(const int32_t* index_sparse_write, const int64_t size_index_write)}; + +%apply (double* ARGOUT_ARRAY1, int64_t DIM1) {(double* const value_sparse_read, const int64_t size_value_read)}; +%apply (int32_t* ARGOUT_ARRAY1, int64_t DIM1) {(int32_t* const index_sparse_read, const int64_t size_index_read)}; +/* Enable write|read_safe functions to convert numpy arrays from orbital list arrays */ +%apply (int32_t* ARGOUT_ARRAY1, int64_t DIM1) {(int32_t* const dset_up_out, const int64_t dim_up_out)}; +%apply (int32_t* ARGOUT_ARRAY1, int64_t DIM1) {(int32_t* const dset_dn_out, const int64_t dim_dn_out)}; +%apply (int64_t* ARGOUT_ARRAY1, int64_t DIM1) {(int64_t* const dset_up_out, const int64_t dim_up_out)}; +%apply (int64_t* ARGOUT_ARRAY1, int64_t DIM1) {(int64_t* const dset_dn_out, const int64_t dim_dn_out)}; +%apply (bitfield_t* IN_ARRAY1, int64_t DIM1) {(const bitfield_t* dset_in, const int64_t dim_in)}; + +/* This tells SWIG to treat char ** dset_in pattern as a special case + Enables access to trexio_[...]_write_dset_str set of functions directly, i.e. + by converting input list of strings from Python into char ** of C +*/ +%typemap(in) char** dset_in { + /* Check if is a list */ + if (PyList_Check($input)) { + int size = PyList_Size($input); + Py_ssize_t i = 0; + $1 = (char **) malloc((size+1)*sizeof(char *)); + for (i = 0; i < size; i++) { + PyObject *o = PyList_GetItem($input, i); + if (PyUnicode_Check(o)) { + $1[i] = PyUnicode_AsUTF8(PyList_GetItem($input,i)); + } else { + PyErr_Format(PyExc_TypeError, "list must contain strings. %d/%d element was not string.", i, size); + free($1); + return NULL; + } + } + $1[i] = 0; + } else { + PyErr_SetString(PyExc_TypeError, "not a list"); + return NULL; + } +} +/* This cleans up the char ** array we malloc-ed before */ +%typemap(freearg) char** dset_in { + free((char *) $1); +} + +/* Parse the header files to generate wrappers */ +%include "trexio_s.h" +%include "trexio.h" diff --git a/python/qmckl.h b/python/qmckl.h new file mode 100644 index 0000000..e17c267 --- /dev/null +++ b/python/qmckl.h @@ -0,0 +1,2093 @@ +/* + * ------------------------------------------ + * QMCkl - Quantum Monte Carlo kernel library + * ------------------------------------------ + * + * Documentation : https://trex-coe.github.io/qmckl + * Issues : https://github.com/trex-coe/qmckl/issues + * + * BSD 3-Clause License + * + * Copyright (c) 2020, TREX Center of Excellence + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * + * + */ + +#ifndef __QMCKL_H__ +#define __QMCKL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +/* /home/evgeny/qmckl/src/qmckl_context_type.h */ +/* Context handling */ + +/* The context variable is a handle for the state of the library, */ +/* and is stored in a data structure which can't be seen outside of */ +/* the library. To simplify compatibility with other languages, the */ +/* pointer to the internal data structure is converted into a 64-bit */ +/* signed integer, defined in the ~qmckl_context~ type. */ +/* A value of ~QMCKL_NULL_CONTEXT~ for the context is equivalent to a */ +/* ~NULL~ pointer. */ + +/* #+NAME: qmckl_context */ + +typedef int64_t qmckl_context ; +#define QMCKL_NULL_CONTEXT (qmckl_context) 0 +/* /home/evgeny/qmckl/src/qmckl_error_type.h */ +/* - */ +/* :PROPERTIES: */ +/* :UNNUMBERED: t */ +/* :END: */ + +/* The library should never make the calling programs abort, nor */ +/* perform any input/output operations. This decision has to be taken */ +/* by the developer of the code calling the library. */ + +/* All the functions return with an exit code, defined as */ +/* #+NAME: type-exit-code */ + +typedef int32_t qmckl_exit_code; + + + +/* #+RESULTS: */ +/* :results: */ + +#define QMCKL_SUCCESS ((qmckl_exit_code) 0) +#define QMCKL_INVALID_ARG_1 ((qmckl_exit_code) 1) +#define QMCKL_INVALID_ARG_2 ((qmckl_exit_code) 2) +#define QMCKL_INVALID_ARG_3 ((qmckl_exit_code) 3) +#define QMCKL_INVALID_ARG_4 ((qmckl_exit_code) 4) +#define QMCKL_INVALID_ARG_5 ((qmckl_exit_code) 5) +#define QMCKL_INVALID_ARG_6 ((qmckl_exit_code) 6) +#define QMCKL_INVALID_ARG_7 ((qmckl_exit_code) 7) +#define QMCKL_INVALID_ARG_8 ((qmckl_exit_code) 8) +#define QMCKL_INVALID_ARG_9 ((qmckl_exit_code) 9) +#define QMCKL_INVALID_ARG_10 ((qmckl_exit_code) 10) +#define QMCKL_INVALID_ARG_11 ((qmckl_exit_code) 11) +#define QMCKL_INVALID_ARG_12 ((qmckl_exit_code) 12) +#define QMCKL_INVALID_ARG_13 ((qmckl_exit_code) 13) +#define QMCKL_INVALID_ARG_14 ((qmckl_exit_code) 14) +#define QMCKL_INVALID_ARG_15 ((qmckl_exit_code) 15) +#define QMCKL_INVALID_ARG_16 ((qmckl_exit_code) 16) +#define QMCKL_INVALID_ARG_17 ((qmckl_exit_code) 17) +#define QMCKL_INVALID_ARG_18 ((qmckl_exit_code) 18) +#define QMCKL_INVALID_ARG_19 ((qmckl_exit_code) 19) +#define QMCKL_INVALID_ARG_20 ((qmckl_exit_code) 20) +#define QMCKL_FAILURE ((qmckl_exit_code) 101) +#define QMCKL_ERRNO ((qmckl_exit_code) 102) +#define QMCKL_INVALID_CONTEXT ((qmckl_exit_code) 103) +#define QMCKL_ALLOCATION_FAILED ((qmckl_exit_code) 104) +#define QMCKL_DEALLOCATION_FAILED ((qmckl_exit_code) 105) +#define QMCKL_NOT_PROVIDED ((qmckl_exit_code) 106) +#define QMCKL_OUT_OF_BOUNDS ((qmckl_exit_code) 107) +#define QMCKL_INVALID_EXIT_CODE ((qmckl_exit_code) 108) +/* /home/evgeny/qmckl/src/qmckl_numprec_type.h */ + + +/* #+RESULTS: */ +/* :results: */ + +#define QMCKL_DEFAULT_PRECISION 53 +#define QMCKL_DEFAULT_RANGE 11 +/* /home/evgeny/qmckl/src/qmckl_context_func.h */ + + +/* The ~qmckl_context_check~ function checks if the domain pointed by */ +/* the pointer is a valid context. It returns the input ~qmckl_context~ */ +/* if the context is valid, ~QMCKL_NULL_CONTEXT~ otherwise. */ + + +qmckl_context +qmckl_context_check (const qmckl_context context) ; + + + +/* The context keeps a /date/ that allows to check which data needs */ +/* to be recomputed. The date is incremented when the context is touched. */ + +/* When a new element is added to the context, the functions */ +/* [[Creation][=qmckl_context_create=]] [[Destroy][=qmckl_context_destroy=]] and [[Copy][=qmckl_context_copy=]] */ +/* should be updated in order to make deep copies. */ + +/* When the electron coordinates have changed, the context is touched */ +/* using the following function. */ + + +qmckl_exit_code +qmckl_context_touch (const qmckl_context context); + +/* Creation */ + +/* To create a new context, ~qmckl_context_create()~ should be used. */ +/* - Upon success, it returns a pointer to a new context with the ~qmckl_context~ type */ +/* - It returns ~QMCKL_NULL_CONTEXT~ upon failure to allocate the internal data structure */ +/* - A new context always has all its members initialized with a NULL value */ + +/* # Header */ + +qmckl_context qmckl_context_create(); + +/* Locking */ + +/* For thread safety, the context may be locked/unlocked. The lock is */ +/* initialized with the ~PTHREAD_MUTEX_RECURSIVE~ attribute, and the */ +/* number of times the thread has locked it is saved in the */ +/* ~lock_count~ attribute. */ + +/* # Header */ + +void qmckl_lock (qmckl_context context); +void qmckl_unlock(qmckl_context context); + +/* TODO Copy */ + +/* ~qmckl_context_copy~ makes a deep copy of a context. It returns */ +/* ~QMCKL_NULL_CONTEXT~ upon failure. */ + +/* # Header */ + +/* +qmckl_context qmckl_context_copy(const qmckl_context context); +*/ + +/* Destroy */ + +/* The context is destroyed with ~qmckl_context_destroy~, leaving the ancestors untouched. */ +/* It frees the context, and returns the previous context. */ + +/* # Header */ + +qmckl_exit_code +qmckl_context_destroy (const qmckl_context context); +/* /home/evgeny/qmckl/src/qmckl_error_func.h */ +/* Decoding errors */ + +/* To decode the error messages, ~qmckl_string_of_error~ converts an */ +/* error code into a string. */ + + +const char* +qmckl_string_of_error (const qmckl_exit_code error); + +/* Updating errors in the context */ + +/* The error is updated in the context using ~qmckl_set_error~. */ +/* When the error is set in the context, it is mandatory to specify */ +/* from which function the error is triggered, and a message */ +/* explaining the error. The exit code can't be ~QMCKL_SUCCESS~. */ + +/* # Header */ + +qmckl_exit_code +qmckl_set_error(qmckl_context context, + const qmckl_exit_code exit_code, + const char* function_name, + const char* message); + +/* Get the error */ + +/* Upon error, the error type and message can be obtained from the */ +/* context using ~qmckl_get_error~. The message and function name */ +/* is returned in the variables provided. Therefore, passing a */ +/* function name and message is mandatory. */ + +/* # Header */ + +qmckl_exit_code +qmckl_get_error(qmckl_context context, + qmckl_exit_code *exit_code, + char* function_name, + char* message); + +/* Failing */ + +/* To make a function fail, the ~qmckl_failwith~ function should be */ +/* called, such that information about the failure is stored in */ +/* the context. The desired exit code is given as an argument, as */ +/* well as the name of the function and an error message. If the */ +/* message is ~NULL~, then the default message obtained by */ +/* ~qmckl_string_of_error~ is used. The return code of the function is */ +/* the desired return code. */ +/* Upon failure, a ~QMCKL_NULL_CONTEXT~ is returned. */ + + +qmckl_exit_code +qmckl_failwith(qmckl_context context, + const qmckl_exit_code exit_code, + const char* function, + const char* message) ; +/* /home/evgeny/qmckl/src/qmckl_blas_func.h */ +/* ~qmckl_dgemm~ */ + +/* Matrix multiplication with a BLAS interface: */ + +/* \[ */ +/* C_{ij} = \beta C_{ij} + \alpha \sum_{k} A_{ik} \cdot B_{kj} */ +/* \] */ + +/* # TODO: Add description about the external library dependence. */ + +/* #+NAME: qmckl_dgemm_args */ +/* | Variable | Type | In/Out | Description | */ +/* |-----------+-----------------+--------+---------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~TransA~ | ~char~ | in | 'T' is transposed | */ +/* | ~TransB~ | ~char~ | in | 'T' is transposed | */ +/* | ~m~ | ~int64_t~ | in | Number of rows of the input matrix | */ +/* | ~n~ | ~int64_t~ | in | Number of columns of the input matrix | */ +/* | ~k~ | ~int64_t~ | in | Number of columns of the input matrix | */ +/* | ~alpha~ | ~double~ | in | \alpha | */ +/* | ~A~ | ~double[][lda]~ | in | Array containing the matrix $A$ | */ +/* | ~lda~ | ~int64_t~ | in | Leading dimension of array ~A~ | */ +/* | ~B~ | ~double[][ldb]~ | in | Array containing the matrix $B$ | */ +/* | ~ldb~ | ~int64_t~ | in | Leading dimension of array ~B~ | */ +/* | ~beta~ | ~double~ | in | \beta | */ +/* | ~C~ | ~double[][ldc]~ | out | Array containing the matrix $C$ | */ +/* | ~ldc~ | ~int64_t~ | in | Leading dimension of array ~C~ | */ + +/* Requirements: */ + +/* - ~context~ is not ~QMCKL_NULL_CONTEXT~ */ +/* - ~m > 0~ */ +/* - ~n > 0~ */ +/* - ~k > 0~ */ +/* - ~lda >= m~ */ +/* - ~ldb >= n~ */ +/* - ~ldc >= n~ */ +/* - ~A~ is allocated with at least $m \times k \times 8$ bytes */ +/* - ~B~ is allocated with at least $k \times n \times 8$ bytes */ +/* - ~C~ is allocated with at least $m \times n \times 8$ bytes */ + +/* #+CALL: generate_c_header(table=qmckl_dgemm_args,rettyp="qmckl_exit_code",fname="qmckl_dgemm") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_dgemm ( + const qmckl_context context, + const char TransA, + const char TransB, + const int64_t m, + const int64_t n, + const int64_t k, + const double alpha, + const double* A, + const int64_t lda, + const double* B, + const int64_t ldb, + const double beta, + double* const C, + const int64_t ldc ); + +/* ~qmckl_adjugate~ */ + +/* Given a matrix $\mathbf{A}$, the adjugate matrix */ +/* $\text{adj}(\mathbf{A})$ is the transpose of the cofactors matrix */ +/* of $\mathbf{A}$. */ + +/* \[ */ +/* \mathbf{B} = \text{adj}(\mathbf{A}) = \text{det}(\mathbf{A}) \, \mathbf{A}^{-1} */ +/* \] */ + +/* See also: https://en.wikipedia.org/wiki/Adjugate_matrix */ + +/* #+NAME: qmckl_adjugate_args */ +/* | Variable | Type | In/Out | Description | */ +/* |-----------+-----------------+--------+------------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~n~ | ~int64_t~ | in | Number of rows and columns of the input matrix | */ +/* | ~A~ | ~double[][lda]~ | in | Array containing the $n \times n$ matrix $A$ | */ +/* | ~lda~ | ~int64_t~ | in | Leading dimension of array ~A~ | */ +/* | ~B~ | ~double[][ldb]~ | out | Adjugate of $A$ | */ +/* | ~ldb~ | ~int64_t~ | in | Leading dimension of array ~B~ | */ +/* | ~det_l~ | ~double~ | inout | determinant of $A$ | */ + +/* Requirements: */ + +/* - ~context~ is not ~QMCKL_NULL_CONTEXT~ */ +/* - ~n > 0~ */ +/* - ~lda >= m~ */ +/* - ~A~ is allocated with at least $m \times m \times 8$ bytes */ +/* - ~ldb >= m~ */ +/* - ~B~ is allocated with at least $m \times m \times 8$ bytes */ + +/* #+CALL: generate_c_header(table=qmckl_adjugate_args,rettyp="qmckl_exit_code",fname="qmckl_adjugate") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_adjugate ( + const qmckl_context context, + const int64_t n, + const double* A, + const int64_t lda, + double* const B, + const int64_t ldb, + double* det_l ); +/* /home/evgeny/qmckl/src/qmckl_numprec_func.h */ +/* Precision */ +/* ~qmckl_context_set_numprec_precision~ modifies the parameter for the */ +/* numerical precision in the context. */ + +/* # Header */ + +qmckl_exit_code qmckl_set_numprec_precision(const qmckl_context context, const int precision); + + + +/* ~qmckl_get_numprec_precision~ returns the value of the numerical precision in the context. */ + + +int32_t qmckl_get_numprec_precision(const qmckl_context context); + +/* Range */ + +/* ~qmckl_set_numprec_range~ modifies the parameter for the numerical */ +/* range in a given context. */ + +/* # Header */ + +qmckl_exit_code qmckl_set_numprec_range(const qmckl_context context, const int range); + + + +/* ~qmckl_get_numprec_range~ returns the value of the numerical range in the context. */ + + +int32_t qmckl_get_numprec_get_range(const qmckl_context context); + +/* Helper functions */ + +/* ~qmckl_get_numprec_epsilon~ returns $\epsilon = 2^{1-n}$ where ~n~ is the precision. */ +/* We need to remove the sign bit from the precision. */ + + +double qmckl_get_numprec_epsilon(const qmckl_context context); +/* /home/evgeny/qmckl/src/qmckl_point_func.h */ +/* Number of points */ + + +qmckl_exit_code qmckl_get_point_num (const qmckl_context context, int64_t* const num); + +/* Point coordinates */ + + +qmckl_exit_code qmckl_get_point(const qmckl_context context, + const char transp, + double* const coord, + const int64_t size_max); + +/* Initialization functions */ + +/* When the data is set in the context, if the arrays are large */ +/* enough, we overwrite the data contained in them. */ + +/* To set the data relative to the points in the context, one of the */ +/* following functions need to be called. */ + + +qmckl_exit_code qmckl_set_point (qmckl_context context, + const char transp, + const double* coord, + const int64_t num); +/* /home/evgeny/qmckl/src/qmckl_nucleus_func.h */ +qmckl_exit_code +qmckl_get_nucleus_num(const qmckl_context context, + int64_t* const num); + +qmckl_exit_code +qmckl_get_nucleus_charge(const qmckl_context context, + double* const charge, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_nucleus_rescale_factor(const qmckl_context context, + double* const rescale_factor_kappa); + +qmckl_exit_code +qmckl_get_nucleus_coord(const qmckl_context context, + const char transp, + double* const coord, + const int64_t size_max); + + + +/* When all the data relative to nuclei have been set, the following */ +/* function returns ~true~. */ + + +bool qmckl_nucleus_provided (const qmckl_context context); + + + +/* To set the data relative to the nuclei in the context, the */ +/* following functions need to be called. */ + + +qmckl_exit_code +qmckl_set_nucleus_num(qmckl_context context, + const int64_t num); + +qmckl_exit_code +qmckl_set_nucleus_charge(qmckl_context context, + const double* charge, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_nucleus_coord(qmckl_context context, + const char transp, + const double* coord, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_nucleus_rescale_factor(qmckl_context context, + const double kappa); + +/* Get */ + + +qmckl_exit_code +qmckl_get_nucleus_nn_distance(qmckl_context context, + double* distance, + const int64_t size_max); + +/* Get */ + + +qmckl_exit_code +qmckl_get_nucleus_nn_distance_rescaled(qmckl_context context, + double* distance_rescaled, + const int64_t size_max); + +/* Get */ + + +qmckl_exit_code qmckl_get_nucleus_repulsion(qmckl_context context, double* const energy); +/* /home/evgeny/qmckl/src/qmckl_electron_func.h */ +bool qmckl_electron_provided (const qmckl_context context); + +/* Number of electrons */ + + +qmckl_exit_code qmckl_get_electron_num (const qmckl_context context, int64_t* const num); +qmckl_exit_code qmckl_get_electron_up_num (const qmckl_context context, int64_t* const up_num); +qmckl_exit_code qmckl_get_electron_down_num (const qmckl_context context, int64_t* const down_num); + +/* Number of walkers */ + +/* A walker is a set of electron coordinates that are arguments of */ +/* the wave function. ~walk_num~ is the number of walkers. */ + + +qmckl_exit_code qmckl_get_electron_walk_num (const qmckl_context context, int64_t* const walk_num); + +/* Scaling factors Kappa */ + + +qmckl_exit_code qmckl_get_electron_rescale_factor_ee (const qmckl_context context, double* const rescale_factor_kappa_ee); +qmckl_exit_code qmckl_get_electron_rescale_factor_en (const qmckl_context context, double* const rescale_factor_kappa_en); + +/* Electron coordinates */ + +/* Returns the current electron coordinates. The pointer is assumed */ +/* to point on a memory block of size ~size_max~ \ge ~3 * elec_num * walk_num~. */ +/* The order of the indices is: */ + +/* | | Normal | Transposed | */ +/* |---------+--------------------------+--------------------------| */ +/* | C | ~[walk_num*elec_num][3]~ | ~[3][walk_num*elec_num]~ | */ +/* | Fortran | ~(3,walk_num*elec_num)~ | ~(walk_num*elec_num, 3)~ | */ + + + +qmckl_exit_code +qmckl_get_electron_coord (const qmckl_context context, + const char transp, + double* const coord, + const int64_t size_max); + +/* Initialization functions */ + +/* To set the data relative to the electrons in the context, the */ +/* following functions need to be called. When the data structure is */ +/* initialized, the internal ~coord_new~ and ~coord_old~ arrays are */ +/* both allocated. */ + + +qmckl_exit_code qmckl_set_electron_num (qmckl_context context, const int64_t up_num, const int64_t down_num); +qmckl_exit_code qmckl_set_electron_walk_num (qmckl_context context, const int64_t walk_num); +qmckl_exit_code qmckl_set_electron_coord (qmckl_context context, const char transp, const double* coord, const int64_t size_max); + +qmckl_exit_code qmckl_set_electron_rescale_factor_ee (qmckl_context context, const double kappa_ee); +qmckl_exit_code qmckl_set_electron_rescale_factor_en (qmckl_context context, const double kappa_en); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_ee_distance(qmckl_context context, double* const distance); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_ee_distance_rescaled(qmckl_context context, double* const distance_rescaled); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_ee_distance_rescaled_deriv_e(qmckl_context context, double* const distance_rescaled_deriv_e); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_ee_potential(qmckl_context context, double* const ee_pot); + + + +/* #+CALL: generate_c_header(table=qmckl_ee_potential_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_ee_potential ( + const qmckl_context context, + const int64_t elec_num, + const int64_t walk_num, + const double* ee_distance, + double* const ee_pot ); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_en_distance(qmckl_context context, double* distance); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_en_distance_rescaled(qmckl_context context, double* distance_rescaled); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_en_distance_rescaled_deriv_e(qmckl_context context, double* distance_rescaled_deriv_e); + +/* Get */ + + +qmckl_exit_code qmckl_get_electron_en_potential(qmckl_context context, double* const en_pot); + + + +/* #+CALL: generate_c_header(table=qmckl_en_potential_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_en_potential ( + const qmckl_context context, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const double* charge, + const double* en_distance, + double* const en_pot ); +/* /home/evgeny/qmckl/src/qmckl_distance_func.h */ +/* ~qmckl_distance_sq~ */ +/* :PROPERTIES: */ +/* :Name: qmckl_distance_sq */ +/* :CRetType: qmckl_exit_code */ +/* :FRetType: qmckl_exit_code */ +/* :END: */ + +/* ~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 */ +/* \] */ + +/* #+NAME: qmckl_distance_sq_args */ +/* | Variable | Type | In/Out | Description | */ +/* |-----------+------------------+--------+-----------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~transa~ | ~char~ | in | Array ~A~ is ~'N'~: Normal, ~'T'~: Transposed | */ +/* | ~transb~ | ~char~ | in | Array ~B~ is ~'N'~: Normal, ~'T'~: Transposed | */ +/* | ~m~ | ~int64_t~ | in | Number of points in the first set | */ +/* | ~n~ | ~int64_t~ | in | Number of points in the second set | */ +/* | ~A~ | ~double[][lda]~ | in | Array containing the $m \times 3$ matrix $A$ | */ +/* | ~lda~ | ~int64_t~ | in | Leading dimension of array ~A~ | */ +/* | ~B~ | ~double[][ldb]~ | in | Array containing the $n \times 3$ matrix $B$ | */ +/* | ~ldb~ | ~int64_t~ | in | Leading dimension of array ~B~ | */ +/* | ~C~ | ~double[n][ldc]~ | out | Array containing the $m \times n$ matrix $C$ | */ +/* | ~ldc~ | ~int64_t~ | in | Leading dimension of array ~C~ | */ + +/* 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 */ + +/* #+CALL: generate_c_header(table=qmckl_distance_sq_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +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* const C, + const int64_t ldc ); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_distance_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_distance ( + 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* const C, + const int64_t ldc ); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_distance_rescaled_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_distance_rescaled ( + 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* const C, + const int64_t ldc, + const double rescale_factor_kappa ); + +/* ~qmckl_distance_rescaled_deriv_e~ */ +/* :PROPERTIES: */ +/* :Name: qmckl_distance_rescaled_deriv_e */ +/* :CRetType: qmckl_exit_code */ +/* :FRetType: qmckl_exit_code */ +/* :END: */ + +/* ~qmckl_distance_rescaled_deriv_e~ computes the matrix of the gradient and laplacian of the */ +/* rescaled distance with respect to the electron coordinates. The derivative is a rank 3 tensor. */ +/* The first dimension has a dimension of 4 of which the first three coordinates */ +/* contains the gradient vector and the last index is the laplacian. */ + + +/* \[ */ +/* C_{ij} = \left( 1 - \exp{-\kappa C_{ij}}\right)/\kappa */ +/* \] */ + +/* Here the gradient is defined as follows: */ + +/* \[ */ +/* \nabla (C_{ij}(\mathbf{r}_{ee})) = \left(\frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta x},\frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta y},\frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta z} \right) */ +/* \] */ +/* and the laplacian is defined as follows: */ + +/* \[ */ +/* \triangle (C_{ij}(r_{ee})) = \frac{\delta^2}{\delta x^2} + \frac{\delta^2}{\delta y^2} + \frac{\delta^2}{\delta z^2} */ +/* \] */ + +/* Using the above three formulae, the expression for the gradient and laplacian is */ +/* as follows: */ + +/* \[ */ +/* \frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta x} = \frac{|(x_i - x_j)|}{r_{ij}} (1 - \kappa R_{ij}) */ +/* \] */ + +/* \[ */ +/* \frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta y} = \frac{|(y_i - y_j)|}{r_{ij}} (1 - \kappa R_{ij}) */ +/* \] */ + +/* \[ */ +/* \frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta z} = \frac{|(z_i - z_j)|}{r_{ij}} (1 - \kappa R_{ij}) */ +/* \] */ + +/* \[ */ +/* \Delta(C_{ij}(r_{ee}) = \left[ \frac{2}{r_{ij}} - \kappa \right] (1-\kappa R_{ij}) */ +/* \] */ + +/* If the input array is normal (~'N'~), the xyz coordinates are in */ +/* the leading dimension: ~[n][3]~ in C and ~(3,n)~ in Fortran. */ + +/* #+NAME: qmckl_distance_rescaled_deriv_e_args */ +/* | Variable | Type | In/Out | Description | */ +/* |------------------------+---------------------+--------+-------------------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~transa~ | ~char~ | in | Array ~A~ is ~'N'~: Normal, ~'T'~: Transposed | */ +/* | ~transb~ | ~char~ | in | Array ~B~ is ~'N'~: Normal, ~'T'~: Transposed | */ +/* | ~m~ | ~int64_t~ | in | Number of points in the first set | */ +/* | ~n~ | ~int64_t~ | in | Number of points in the second set | */ +/* | ~A~ | ~double[][lda]~ | in | Array containing the $m \times 3$ matrix $A$ | */ +/* | ~lda~ | ~int64_t~ | in | Leading dimension of array ~A~ | */ +/* | ~B~ | ~double[][ldb]~ | in | Array containing the $n \times 3$ matrix $B$ | */ +/* | ~ldb~ | ~int64_t~ | in | Leading dimension of array ~B~ | */ +/* | ~C~ | ~double[4][n][ldc]~ | out | Array containing the $4 \times m \times n$ matrix $C$ | */ +/* | ~ldc~ | ~int64_t~ | in | Leading dimension of array ~C~ | */ +/* | ~rescale_factor_kappa~ | ~double~ | in | Factor for calculating rescaled distances derivatives | */ + +/* 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 $4 \times m \times n \times 8$ bytes */ + +/* #+CALL: generate_c_header(table=qmckl_distance_rescaled_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_distance_rescaled_deriv_e ( + 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* const C, + const int64_t ldc, + const double rescale_factor_kappa ); +/* /home/evgeny/qmckl/src/qmckl_ao_func.h */ + + +/* To set the basis set, all the following functions need to be */ +/* called. */ + + +qmckl_exit_code +qmckl_set_ao_basis_type (qmckl_context context, + const char basis_type); + +qmckl_exit_code +qmckl_set_ao_basis_shell_num (qmckl_context context, + const int64_t shell_num); + +qmckl_exit_code +qmckl_set_ao_basis_prim_num (qmckl_context context, + const int64_t prim_num); + +qmckl_exit_code +qmckl_set_ao_basis_ao_num (qmckl_context context, + const int64_t ao_num); + +qmckl_exit_code +qmckl_set_ao_basis_nucleus_index (qmckl_context context, + const int64_t* nucleus_index, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_nucleus_shell_num (qmckl_context context, + const int64_t* nucleus_shell_num, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_shell_ang_mom (qmckl_context context, + const int32_t* shell_ang_mom, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_shell_prim_num (qmckl_context context, + const int64_t* shell_prim_num, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_shell_prim_index (qmckl_context context, + const int64_t* shell_prim_index, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_shell_factor (qmckl_context context, + const double* shell_factor, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_exponent (qmckl_context context, + const double* exponent, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_coefficient (qmckl_context context, + const double* coefficient, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_prim_factor (qmckl_context context, + const double* prim_factor, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_ao_factor (qmckl_context context, + const double* ao_factor, + const int64_t size_max); + +qmckl_exit_code +qmckl_set_ao_basis_cartesian (qmckl_context context, + const bool cartesian); + +/* C interface */ + + +qmckl_exit_code +qmckl_get_ao_basis_type (const qmckl_context context, + char* const basis_type); + +qmckl_exit_code +qmckl_get_ao_basis_shell_num (const qmckl_context context, + int64_t* const shell_num); + +qmckl_exit_code +qmckl_get_ao_basis_prim_num (const qmckl_context context, + int64_t* const prim_num); + +qmckl_exit_code +qmckl_get_ao_basis_nucleus_shell_num (const qmckl_context context, + int64_t* const nucleus_shell_num, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_nucleus_index (const qmckl_context context, + int64_t* const nucleus_index, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_shell_ang_mom (const qmckl_context context, + int32_t* const shell_ang_mom, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_shell_prim_num (const qmckl_context context, + int64_t* const shell_prim_num, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_shell_prim_index (const qmckl_context context, + int64_t* const shell_prim_index, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_shell_factor (const qmckl_context context, + double* const shell_factor, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_exponent (const qmckl_context context, + double* const exponent, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_coefficient (const qmckl_context context, + double* const coefficient, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_prim_factor (const qmckl_context context, + double* const prim_factor, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_ao_num (const qmckl_context context, + int64_t* const ao_num); + +qmckl_exit_code +qmckl_get_ao_basis_ao_factor (const qmckl_context context, + double* const ao_factor, + const int64_t size_max); + + + + +/* When all the data for the AOs have been provided, the following */ +/* function returns ~true~. */ + + +bool qmckl_ao_basis_provided (const qmckl_context context); + +/* Access functions */ + + +qmckl_exit_code +qmckl_get_ao_basis_primitive_vgl (qmckl_context context, + double* const primitive_vgl, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_shell_vgl (qmckl_context context, + double* const shell_vgl, + const int64_t size_max); + +qmckl_exit_code +qmckl_get_ao_basis_ao_vgl (qmckl_context context, + double* const ao_vgl, + const int64_t size_max); + + + +/* Uses the give array to compute the VGL. */ + + +qmckl_exit_code +qmckl_get_ao_basis_ao_vgl_inplace (qmckl_context context, + double* const ao_vgl, + const int64_t size_max); + +qmckl_exit_code +qmckl_ao_gaussian_vgl(const qmckl_context context, + const double *X, + const double *R, + const int64_t *n, + const int64_t *A, + const double *VGL, + const int64_t ldv); + +/* Computation of primitives */ +/* :PROPERTIES: */ +/* :Name: qmckl_compute_ao_basis_primitive_gaussian_vgl */ +/* :CRetType: qmckl_exit_code */ +/* :FRetType: qmckl_exit_code */ +/* :END: */ + +/* #+NAME: qmckl_ao_basis_primitive_gaussian_vgl_args */ +/* | Variable | Type | In/Out | Description | */ +/* |----------------------+----------------------------------+--------+--------------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~prim_num~ | ~int64_t~ | in | Number of primitives | */ +/* | ~point_num~ | ~int64_t~ | in | Number of points considered | */ +/* | ~nucl_num~ | ~int64_t~ | in | Number of nuclei | */ +/* | ~nucleus_prim_index~ | ~int64_t[nucl_num]~ | in | Index of the 1st primitive of each nucleus | */ +/* | ~coord~ | ~double[3][point_num]~ | in | Coordinates | */ +/* | ~nucl_coord~ | ~double[3][nucl_num]~ | in | Nuclear coordinates | */ +/* | ~expo~ | ~double[prim_num]~ | in | Exponents of the primitives | */ +/* | ~primitive_vgl~ | ~double[point_num][5][prim_num]~ | out | Value, gradients and Laplacian of the primitives | */ + +/* #+CALL: generate_c_header(table=qmckl_ao_basis_primitive_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_basis_primitive_gaussian_vgl")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_ao_basis_primitive_gaussian_vgl ( + const qmckl_context context, + const int64_t prim_num, + const int64_t point_num, + const int64_t nucl_num, + const int64_t* nucleus_prim_index, + const double* coord, + const double* nucl_coord, + const double* expo, + double* const primitive_vgl ); + +/* Computation of shells */ +/* :PROPERTIES: */ +/* :Name: qmckl_compute_ao_basis_shell_gaussian_vgl */ +/* :CRetType: qmckl_exit_code */ +/* :FRetType: qmckl_exit_code */ +/* :END: */ + +/* #+NAME: qmckl_ao_basis_shell_gaussian_vgl_args */ +/* | Variable | Type | In/Out | Description | */ +/* |---------------------+-----------------------------------+--------+----------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~prim_num~ | ~int64_t~ | in | Number of primitives | */ +/* | ~shell_num~ | ~int64_t~ | in | Number of shells | */ +/* | ~point_num~ | ~int64_t~ | in | Number of points | */ +/* | ~nucl_num~ | ~int64_t~ | in | Number of nuclei | */ +/* | ~nucleus_shell_num~ | ~int64_t[nucl_num]~ | in | Number of shells for each nucleus | */ +/* | ~nucleus_index~ | ~int64_t[nucl_num]~ | in | Index of the 1st shell of each nucleus | */ +/* | ~nucleus_range~ | ~double[nucl_num]~ | in | Range of the nucleus | */ +/* | ~shell_prim_index~ | ~int64_t[shell_num]~ | in | Index of the 1st primitive of each shell | */ +/* | ~shell_prim_num~ | ~int64_t[shell_num]~ | in | Number of primitives per shell | */ +/* | ~coord~ | ~double[3][point_num]~ | in | Coordinates | */ +/* | ~nucl_coord~ | ~double[3][nucl_num]~ | in | Nuclear coordinates | */ +/* | ~expo~ | ~double[prim_num]~ | in | Exponents of the primitives | */ +/* | ~coef_normalized~ | ~double[prim_num]~ | in | Coefficients of the primitives | */ +/* | ~shell_vgl~ | ~double[point_num][5][shell_num]~ | out | Value, gradients and Laplacian of the shells | */ + +/* #+CALL: generate_c_header(table=qmckl_ao_basis_shell_gaussian_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_ao_basis_shell_gaussian_vgl")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_ao_basis_shell_gaussian_vgl ( + const qmckl_context context, + const int64_t prim_num, + const int64_t shell_num, + const int64_t point_num, + const int64_t nucl_num, + const int64_t* nucleus_shell_num, + const int64_t* nucleus_index, + const double* nucleus_range, + const int64_t* shell_prim_index, + const int64_t* shell_prim_num, + const double* coord, + const double* nucl_coord, + const double* expo, + const double* coef_normalized, + double* const shell_vgl ); + +/* General functions for Powers of $x-X_i$ */ +/* :PROPERTIES: */ +/* :Name: qmckl_ao_power */ +/* :CRetType: qmckl_exit_code */ +/* :FRetType: qmckl_exit_code */ +/* :END: */ + +/* The ~qmckl_ao_power~ function computes all the powers of the ~n~ */ +/* input data up to the given maximum value given in input for each of */ +/* the $n$ points: */ + +/* \[ P_{ik} = X_i^k \] */ + +/* #+NAME: qmckl_ao_power_args */ +/* | Variable | Type | In/Out | Description | */ +/* |-----------+-----------------+--------+---------------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~n~ | int64_t | in | Number of values | */ +/* | ~X~ | double[n] | in | Array containing the input values | */ +/* | ~LMAX~ | int32_t[n] | in | Array containing the maximum power for each value | */ +/* | ~P~ | double[n][ldp] | out | Array containing all the powers of ~X~ | */ +/* | ~ldp~ | int64_t | in | Leading dimension of array ~P~ | */ + +/* Requirements: */ + +/* - ~context~ is not ~QMCKL_NULL_CONTEXT~ */ +/* - ~n~ > 0 */ +/* - ~X~ is allocated with at least $n \times 8$ bytes */ +/* - ~LMAX~ is allocated with at least $n \times 4$ bytes */ +/* - ~P~ is allocated with at least $n \times \max_i \text{LMAX}_i \times 8$ bytes */ +/* - ~LDP~ >= $\max_i$ ~LMAX[i]~ */ + +/* #+CALL: generate_c_header(table=qmckl_ao_power_args,rettyp=get_value("CRetType"),fname="qmckl_ao_power") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_ao_power ( + const qmckl_context context, + const int64_t n, + const double* X, + const int32_t* LMAX, + double* const P, + const int64_t ldp ); + +/* General functions for Value, Gradient and Laplacian of a polynomial */ +/* :PROPERTIES: */ +/* :Name: qmckl_ao_polynomial_vgl */ +/* :CRetType: qmckl_exit_code */ +/* :FRetType: qmckl_exit_code */ +/* :END: */ + +/* A polynomial is centered on a nucleus $\mathbf{R}_i$ */ + +/* \[ */ +/* P_l(\mathbf{r},\mathbf{R}_i) = (x-X_i)^a (y-Y_i)^b (z-Z_i)^c */ +/* \] */ + +/* The gradients with respect to electron coordinates are */ + +/* \begin{eqnarray*} */ +/* \frac{\partial }{\partial x} P_l\left(\mathbf{r},\mathbf{R}_i \right) & */ +/* = & a (x-X_i)^{a-1} (y-Y_i)^b (z-Z_i)^c \\ */ +/* \frac{\partial }{\partial y} P_l\left(\mathbf{r},\mathbf{R}_i \right) & */ +/* = & b (x-X_i)^a (y-Y_i)^{b-1} (z-Z_i)^c \\ */ +/* \frac{\partial }{\partial z} P_l\left(\mathbf{r},\mathbf{R}_i \right) & */ +/* = & c (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1} \\ */ +/* \end{eqnarray*} */ + +/* and the Laplacian is */ + +/* \begin{eqnarray*} */ +/* \left( \frac{\partial }{\partial x^2} + */ +/* \frac{\partial }{\partial y^2} + */ +/* \frac{\partial }{\partial z^2} \right) P_l */ +/* \left(\mathbf{r},\mathbf{R}_i \right) & = & */ +/* a(a-1) (x-X_i)^{a-2} (y-Y_i)^b (z-Z_i)^c + \\ */ +/* && b(b-1) (x-X_i)^a (y-Y_i)^{b-1} (z-Z_i)^c + \\ */ +/* && c(c-1) (x-X_i)^a (y-Y_i)^b (z-Z_i)^{c-1}. */ +/* \end{eqnarray*} */ + +/* ~qmckl_ao_polynomial_vgl~ computes the values, gradients and */ +/* Laplacians at a given point in space, of all polynomials with an */ +/* angular momentum up to ~lmax~. */ + +/* #+NAME: qmckl_ao_polynomial_vgl_args */ +/* | Variable | Type | In/Out | Description | */ +/* |-----------+-------------------+--------+------------------------------------------------------| */ +/* | ~context~ | ~qmckl_context~ | in | Global state | */ +/* | ~X~ | ~double[3]~ | in | Array containing the coordinates of the points | */ +/* | ~R~ | ~double[3]~ | in | Array containing the x,y,z coordinates of the center | */ +/* | ~lmax~ | ~int32_t~ | in | Maximum angular momentum | */ +/* | ~n~ | ~int64_t~ | inout | Number of computed polynomials | */ +/* | ~L~ | ~int32_t[n][ldl]~ | out | Contains a,b,c for all ~n~ results | */ +/* | ~ldl~ | ~int64_t~ | in | Leading dimension of ~L~ | */ +/* | ~VGL~ | ~double[n][ldv]~ | out | Value, gradients and Laplacian of the polynomials | */ +/* | ~ldv~ | ~int64_t~ | in | Leading dimension of array ~VGL~ | */ + +/* Requirements: */ + +/* - ~context~ \ne ~QMCKL_NULL_CONTEXT~ */ +/* - ~n~ > 0 */ +/* - ~lmax~ >= 0 */ +/* - ~ldl~ >= 3 */ +/* - ~ldv~ >= 5 */ +/* - ~X~ is allocated with at least $3 \times 8$ bytes */ +/* - ~R~ is allocated with at least $3 \times 8$ bytes */ +/* - ~n~ >= ~(lmax+1)(lmax+2)(lmax+3)/6~ */ +/* - ~L~ is allocated with at least $3 \times n \times 4$ bytes */ +/* - ~VGL~ is allocated with at least $5 \times n \times 8$ bytes */ +/* - On output, ~n~ should be equal to ~(lmax+1)(lmax+2)(lmax+3)/6~ */ +/* - On output, the powers are given in the following order (l=a+b+c): */ +/* - Increasing values of ~l~ */ +/* - Within a given value of ~l~, alphabetical order of the */ +/* string made by a*"x" + b*"y" + c*"z" (in Python notation). */ +/* For example, with a=0, b=2 and c=1 the string is "yyz" */ + +/* #+CALL: generate_c_header(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_ao_polynomial_vgl ( + const qmckl_context context, + const double* X, + const double* R, + const int32_t lmax, + int64_t* n, + int32_t* const L, + const int64_t ldl, + double* const VGL, + const int64_t ldv ); + + + +/* #+CALL: generate_c_header(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_ao_polynomial_vgl_doc") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_ao_polynomial_vgl_doc ( + const qmckl_context context, + const double* X, + const double* R, + const int32_t lmax, + int64_t* n, + int32_t* const L, + const int64_t ldl, + double* const VGL, + const int64_t ldv ); + + + +/* #+CALL: generate_c_header(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_ao_polynomial_transp_vgl") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_ao_polynomial_transp_vgl ( + const qmckl_context context, + const double* X, + const double* R, + const int32_t lmax, + int64_t* n, + int32_t* const L, + const int64_t ldl, + double* const VGL, + const int64_t ldv ); + + + +/* #+CALL: generate_c_header(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_ao_polynomial_transp_vgl_doc") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_ao_polynomial_transp_vgl_doc ( + const qmckl_context context, + const double* X, + const double* R, + const int32_t lmax, + int64_t* n, + int32_t* const L, + const int64_t ldl, + double* const VGL, + const int64_t ldv ); + + + +/* #+CALL: generate_c_header(table=qmckl_ao_polynomial_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_ao_polynomial_transp_vgl_hpc") */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_ao_polynomial_transp_vgl_hpc ( + const qmckl_context context, + const double* X, + const double* R, + const int32_t lmax, + int64_t* n, + int32_t* const L, + const int64_t ldl, + double* const VGL, + const int64_t ldv ); +/* /home/evgeny/qmckl/src/qmckl_mo_func.h */ +/* Access functions */ + + +qmckl_exit_code +qmckl_get_mo_basis_mo_num (const qmckl_context context, + int64_t* mo_num); + +qmckl_exit_code +qmckl_get_mo_basis_coefficient (const qmckl_context context, + double* const coefficient, + const int64_t size_max); + + + +/* When all the data for the AOs have been provided, the following */ +/* function returns ~true~. */ + + +bool qmckl_mo_basis_provided (const qmckl_context context); + +/* Initialization functions */ + +/* To set the basis set, all the following functions need to be */ +/* called. */ + + +qmckl_exit_code qmckl_set_mo_basis_mo_num (qmckl_context context, const int64_t mo_num); +qmckl_exit_code qmckl_set_mo_basis_coefficient (qmckl_context context, const double * coefficient); + +/* Get */ + + +qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_vgl); + + + +/* #+CALL: generate_c_header(table=qmckl_mo_basis_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_vgl")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_mo_basis_vgl ( + const qmckl_context context, + const int64_t ao_num, + const int64_t mo_num, + const int64_t point_num, + const double* coef_normalized, + const double* ao_vgl, + double* const mo_vgl ); +/* /home/evgeny/qmckl/src/qmckl_determinant_func.h */ + + +/* When all the data for the slater determinants have been provided, the following */ +/* function returns ~true~. */ + + +bool qmckl_determinant_provided (const qmckl_context context); + +/* Initialization functions */ + +/* To set the basis set, all the following functions need to be */ +/* called. */ + + +qmckl_exit_code qmckl_set_determinant_type (const qmckl_context context, const char t); +qmckl_exit_code qmckl_set_determinant_walk_num (const qmckl_context context, const int64_t walk_num); +qmckl_exit_code qmckl_set_determinant_det_num_alpha (const qmckl_context context, const int64_t det_num_alpha); +qmckl_exit_code qmckl_set_determinant_det_num_beta (const qmckl_context context, const int64_t det_num_beta); +qmckl_exit_code qmckl_set_determinant_mo_index_alpha (const qmckl_context context, const int64_t* mo_index_alpha); +qmckl_exit_code qmckl_set_determinant_mo_index_beta (const qmckl_context context, const int64_t* mo_index_beta); + +/* Get */ + + +qmckl_exit_code qmckl_get_det_vgl_alpha(qmckl_context context, double* const det_vgl_alpha); +qmckl_exit_code qmckl_get_det_vgl_beta(qmckl_context context, double* const det_vgl_beta); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_det_vgl_alpha_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_vgl_alpha")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_det_vgl_alpha ( + const qmckl_context context, + const int64_t det_num_alpha, + const int64_t walk_num, + const int64_t alpha_num, + const int64_t beta_num, + const int64_t elec_num, + const int64_t* mo_index_alpha, + const int64_t mo_num, + const double* mo_vgl, + double* const det_vgl_alpha ); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_det_vgl_beta_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_vgl_beta")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_det_vgl_beta ( + const qmckl_context context, + const int64_t det_num_beta, + const int64_t walk_num, + const int64_t alpha_num, + const int64_t beta_num, + const int64_t elec_num, + const int64_t* mo_index_beta, + const int64_t mo_num, + const double* mo_vgl, + double* const det_vgl_beta ); + +/* Get */ + + +qmckl_exit_code qmckl_get_det_inv_matrix_alpha(qmckl_context context, double* const det_inv_matrix_alpha); +qmckl_exit_code qmckl_get_det_inv_matrix_beta(qmckl_context context, double* const det_inv_matrix_beta); +qmckl_exit_code qmckl_get_det_adj_matrix_alpha(qmckl_context context, double* const det_adj_matrix_alpha); +qmckl_exit_code qmckl_get_det_adj_matrix_beta(qmckl_context context, double* const det_adj_matrix_beta); +qmckl_exit_code qmckl_get_det_alpha(qmckl_context context, double* const det_adj_matrix_alpha); +qmckl_exit_code qmckl_get_det_beta(qmckl_context context, double* const det_adj_matrix_beta); + + + +/* #+CALL: generate_c_header(table=qmckl_det_inv_matrix_alpha_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_inv_matrix_alpha")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_det_inv_matrix_alpha ( + const qmckl_context context, + const int64_t det_num_alpha, + const int64_t walk_num, + const int64_t alpha_num, + const double* det_vgl_alpha, + double* const det_value_alpha, + double* const det_adj_matrix_alpha, + double* const det_inv_matrix_alpha ); + + + +/* #+CALL: generate_c_header(table=qmckl_det_inv_matrix_beta_args,rettyp=get_value("CRetType"),fname="qmckl_compute_det_inv_matrix_beta")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_det_inv_matrix_beta ( + const qmckl_context context, + const int64_t det_num_beta, + const int64_t walk_num, + const int64_t beta_num, + const double* det_vgl_beta, + double* const det_value_beta, + double* const det_adj_matrix_beta, + double* const det_inv_matrix_beta ); +/* /home/evgeny/qmckl/src/qmckl_sherman_morrison_woodbury_func.h */ +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_sherman_morrison_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_sherman_morrison( + const qmckl_context context, + const uint64_t LDS, + const uint64_t Dim, + const uint64_t N_updates, + const double* Updates, + const uint64_t* Updates_index, + const double breakdown, + double* Slater_inv, + double* determinant); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_woodbury_2_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_woodbury_2( + const qmckl_context context, + const uint64_t LDS, + const uint64_t Dim, + const double* Updates, + const uint64_t* Updates_index, + const double breakdown, + double* Slater_inv, + double* determinant); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_woodbury_3_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_woodbury_3( + const qmckl_context context, + const uint64_t LDS, + const uint64_t Dim, + const double* Updates, + const uint64_t* Updates_index, + const double breakdown, + double* Slater_inv, +double* determinant); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_sherman_morrison_splitting_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_sherman_morrison_splitting( + const qmckl_context context, + const uint64_t LDS, + const uint64_t Dim, + const uint64_t N_updates, + const double* Updates, + const uint64_t* Updates_index, + const double breakdown, + double* Slater_inv, + double* determinant); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_sherman_morrison_smw32s_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_sherman_morrison_smw32s( + const qmckl_context context, + const uint64_t LDS, + const uint64_t Dim, + const uint64_t N_updates, + const double* Updates, + const uint64_t* Updates_index, + const double breakdown, + double* Slater_inv, + double* determinant); + +/* C header */ + +/* #+CALL: generate_c_header(table=qmckl_slagel_splitting_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_slagel_splitting ( + const uint64_t LDS, + const uint64_t Dim, + const uint64_t N_updates, + const double* Updates, + const uint64_t* Updates_index, + const double breakdown, + double* Slater_inv, + double* later_updates, + uint64_t* later_index, + uint64_t* later, + double* determinant); +/* /home/evgeny/qmckl/src/qmckl_jastrow_func.h */ + + + +/* The ~uninitialized~ integer contains one bit set to one for each */ +/* initialization function which has not been called. It becomes equal */ +/* to zero after all initialization functions have been called. The */ +/* struct is then initialized and ~provided == true~. */ +/* Some values are initialized by default, and are not concerned by */ +/* this mechanism. */ + + +qmckl_exit_code qmckl_init_jastrow(qmckl_context context); + +/* Access functions */ + + +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_nucl_num (qmckl_context context, int64_t* const type_nucl_num); +qmckl_exit_code qmckl_get_jastrow_type_nucl_vector (qmckl_context context, int64_t* const type_nucl_num, const int64_t size_max); +qmckl_exit_code qmckl_get_jastrow_aord_vector (qmckl_context context, double * const aord_vector, const int64_t size_max); +qmckl_exit_code qmckl_get_jastrow_bord_vector (qmckl_context context, double * const bord_vector, const int64_t size_max); +qmckl_exit_code qmckl_get_jastrow_cord_vector (qmckl_context context, double * const cord_vector, const int64_t size_max); + + + +/* Along with these core functions, calculation of the jastrow factor */ +/* requires the following additional information to be set: */ + + +/* When all the data for the AOs have been provided, the following */ +/* function returns ~true~. */ + + +bool qmckl_jastrow_provided (const qmckl_context context); + +/* Initialization functions */ + +/* To prepare for the Jastrow and its derivative, all the following functions need to be */ +/* called. */ + + +qmckl_exit_code qmckl_set_jastrow_ord_num (qmckl_context context, const int64_t aord_num, const int64_t bord_num, const int64_t cord_num); +qmckl_exit_code qmckl_set_jastrow_type_nucl_num (qmckl_context context, const int64_t type_nucl_num); +qmckl_exit_code qmckl_set_jastrow_type_nucl_vector (qmckl_context context, const int64_t* type_nucl_vector, const int64_t nucl_num); +qmckl_exit_code qmckl_set_jastrow_aord_vector (qmckl_context context, const double * aord_vector, const int64_t size_max); +qmckl_exit_code qmckl_set_jastrow_bord_vector (qmckl_context context, const double * bord_vector, const int64_t size_max); +qmckl_exit_code qmckl_set_jastrow_cord_vector (qmckl_context context, const double * cord_vector, const int64_t size_max); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_asymp_jasb(qmckl_context context, + double* const asymp_jasb, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_asymp_jasb ( + const qmckl_context context, + const int64_t bord_num, + const double* bord_vector, + const double rescale_factor_kappa_ee, + double* const asymp_jasb ); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_factor_ee(qmckl_context context, + double* const factor_ee, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_ee ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t up_num, + const int64_t bord_num, + const double* bord_vector, + const double* ee_distance_rescaled, + const double* asymp_jasb, + double* const factor_ee ); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_factor_ee_deriv_e(qmckl_context context, + double* const factor_ee_deriv_e, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_ee_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_ee_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t up_num, + const int64_t bord_num, + const double* bord_vector, + const double* ee_distance_rescaled, + const double* ee_distance_rescaled_deriv_e, + const double* asymp_jasb, + double* const factor_ee_deriv_e ); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_factor_en(qmckl_context context, + double* const factor_en, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_en_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_en ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const int64_t aord_num, + const double* aord_vector, + const double* en_distance_rescaled, + double* const factor_en ); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_factor_en_deriv_e(qmckl_context context, + double* const factor_en_deriv_e, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_en_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_en_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const int64_t aord_num, + const double* aord_vector, + const double* en_distance_rescaled, + const double* en_distance_rescaled_deriv_e, + double* const factor_en_deriv_e ); + +/* Get */ + + +qmckl_exit_code +qmckl_get_jastrow_een_rescaled_e(qmckl_context context, + double* const distance_rescaled, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_een_rescaled_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t cord_num, + const double rescale_factor_kappa_ee, + const double* ee_distance, + double* const een_rescaled_e ); + +/* Get */ + + +qmckl_exit_code +qmckl_get_jastrow_een_rescaled_e_deriv_e(qmckl_context context, + double* const distance_rescaled, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_e_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_een_rescaled_e_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t cord_num, + const double rescale_factor_kappa_ee, + const double* coord_new, + const double* ee_distance, + const double* een_rescaled_e, + double* const een_rescaled_e_deriv_e ); + +/* Get */ + + +qmckl_exit_code +qmckl_get_jastrow_een_rescaled_n(qmckl_context context, + double* const distance_rescaled, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_n_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_een_rescaled_n ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const double rescale_factor_kappa_en, + const double* en_distance, + double* const een_rescaled_n ); + +/* Get */ + + +qmckl_exit_code +qmckl_get_jastrow_een_rescaled_n_deriv_e(qmckl_context context, + double* const distance_rescaled, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_factor_een_rescaled_n_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_een_rescaled_n_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const double rescale_factor_kappa_en, + const double* coord_new, + const double* coord, + const double* en_distance, + const double* een_rescaled_n, + double* const een_rescaled_n_deriv_e ); + +/* Get */ + + +qmckl_exit_code qmckl_get_jastrow_dim_cord_vect(qmckl_context context, int64_t* const dim_cord_vect); +qmckl_exit_code qmckl_get_jastrow_cord_vect_full(qmckl_context context, double* const cord_vect_full); +qmckl_exit_code qmckl_get_jastrow_lkpm_combined_index(qmckl_context context, int64_t* const lkpm_combined_index); +qmckl_exit_code qmckl_get_jastrow_tmp_c(qmckl_context context, double* const tmp_c); +qmckl_exit_code qmckl_get_jastrow_dtmp_c(qmckl_context context, double* const dtmp_c); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_dim_cord_vect_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_dim_cord_vect ( + const qmckl_context context, + const int64_t cord_num, + int64_t* const dim_cord_vect ); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_cord_vect_full_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_cord_vect_full ( + const qmckl_context context, + const int64_t nucl_num, + const int64_t dim_cord_vect, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const double* cord_vector, + double* const cord_vect_full ); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_lkpm_combined_index_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_lkpm_combined_index ( + const qmckl_context context, + const int64_t cord_num, + const int64_t dim_cord_vect, + int64_t* const lpkm_combined_index ); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_tmp_c_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_tmp_c ( + const qmckl_context context, + const int64_t cord_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const double* een_rescaled_e, + const double* een_rescaled_n, + double* const tmp_c ); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_dtmp_c_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_dtmp_c ( + const qmckl_context context, + const int64_t cord_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const double* een_rescaled_e_deriv_e, + const double* een_rescaled_n, + double* const dtmp_c ); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_factor_een(qmckl_context context, + double* const factor_een, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_naive_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_een_naive ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const double* cord_vect_full, + const int64_t* lkpm_combined_index, + const double* een_rescaled_e, + const double* een_rescaled_n, + double* const factor_een ); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_een ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const double* cord_vect_full, + const int64_t* lkpm_combined_index, + const double* een_rescaled_e, + const double* een_rescaled_n, + double* const factor_een ); + +/* Get */ + +qmckl_exit_code +qmckl_get_jastrow_factor_een_deriv_e(qmckl_context context, + double* const factor_een_deriv_e, + const int64_t size_max); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_deriv_e_naive_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_een_deriv_e_naive ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const double* cord_vect_full, + const int64_t* lkpm_combined_index, + const double* een_rescaled_e, + const double* een_rescaled_n, + const double* een_rescaled_e_deriv_e, + const double* een_rescaled_n_deriv_e, + double* const factor_een_deriv_e ); + + + +/* #+CALL: generate_c_header(table=qmckl_factor_een_deriv_e_args,rettyp=get_value("CRetType"),fname=get_value("Name")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_factor_een_deriv_e ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const int64_t dim_cord_vect, + const double* cord_vect_full, + const int64_t* lkpm_combined_index, + const double* tmp_c, + const double* dtmp_c, + const double* een_rescaled_n, + const double* een_rescaled_n_deriv_e, + double* const factor_een_deriv_e ); +/* /home/evgeny/qmckl/src/qmckl_local_energy_func.h */ +/* Get */ + + +qmckl_exit_code qmckl_get_kinetic_energy(qmckl_context context, double* const kinetic_energy); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_kinetic_energy_args,rettyp=get_value("CRetType"),fname="qmckl_compute_kinetic_energy")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_kinetic_energy ( + const qmckl_context context, + const int64_t walk_num, + const int64_t det_num_alpha, + const int64_t det_num_beta, + const int64_t alpha_num, + const int64_t beta_num, + const int64_t elec_num, + const int64_t* mo_index_alpha, + const int64_t* mo_index_beta, + const int64_t mo_num, + const double* mo_vgl, + const double* det_value_alpha, + const double* det_value_beta, + const double* det_inv_matrix_alpha, + const double* det_inv_matrix_beta, + double* const e_kin ); + +/* Get */ + + +qmckl_exit_code qmckl_get_potential_energy(qmckl_context context, double* const potential_energy); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_potential_energy_args,rettyp=get_value("CRetType"),fname="qmckl_compute_potential_energy")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_potential_energy ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const double* ee_pot, + const double* en_pot, + const double repulsion, + double* const e_pot ); + +/* Get */ + + +qmckl_exit_code qmckl_get_local_energy(qmckl_context context, double* const local_energy); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_local_energy_args,rettyp=get_value("CRetType"),fname="qmckl_compute_local_energy")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_local_energy ( + const qmckl_context context, + const int64_t walk_num, + const double* e_kin, + const double* e_pot, + double* const e_local ); + +/* Get */ + + +qmckl_exit_code qmckl_get_drift_vector(qmckl_context context, double* const drift_vector); + + + +/* #+CALL: generate_c_header(table=qmckl_compute_drift_vector_args,rettyp=get_value("CRetType"),fname="qmckl_compute_drift_vector")) */ + +/* #+RESULTS: */ + +qmckl_exit_code qmckl_compute_drift_vector ( + const qmckl_context context, + const int64_t walk_num, + const int64_t det_num_alpha, + const int64_t det_num_beta, + const int64_t alpha_num, + const int64_t beta_num, + const int64_t elec_num, + const int64_t* mo_index_alpha, + const int64_t* mo_index_beta, + const int64_t mo_num, + const double* mo_vgl, + const double* det_inv_matrix_alpha, + const double* det_inv_matrix_beta, + double* const r_drift ); +/* /home/evgeny/qmckl/src/qmckl_trexio_func.h */ +qmckl_exit_code +qmckl_trexio_read(const qmckl_context context, + const char* file_name, + const int64_t size_max); +#ifdef __cplusplus +} +#endif +#endif