aboutsummaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/argcargv.i92
-rw-r--r--Python/classwrapper.i282
-rw-r--r--Python/numpy.i3166
-rw-r--r--Python/pywarpx/AMReX.py8
-rw-r--r--Python/pywarpx/PGroup.py197
-rw-r--r--Python/pywarpx/WarpX.py15
-rw-r--r--Python/pywarpx/__init__.py2
-rwxr-xr-xPython/pywarpx/_libwarpx.py524
-rw-r--r--Python/pywarpx/timestepper.py52
-rw-r--r--Python/setup.py41
-rw-r--r--Python/warpxC.i53
11 files changed, 637 insertions, 3795 deletions
diff --git a/Python/argcargv.i b/Python/argcargv.i
deleted file mode 100644
index 717fe7334..000000000
--- a/Python/argcargv.i
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------
- * --- Argc & Argv ---
- * ------------------------------------------------------------ */
-
-%fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") {
-SWIGINTERN int
-SWIG_AsArgcArgv(PyObject *input,
- swig_type_info *ppchar_info,
- size_t *argc, char ***argv, int *owner)
-{
- void *vptr;
- int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0);
- if (!SWIG_IsOK(res)) {
- int list = 0;
- PyErr_Clear();
- list = PyList_Check(input);
- if (list || PyTuple_Check(input)) {
- size_t i = 0;
- size_t size = list ? PyList_Size(input) : PyTuple_Size(input);
- if (argc) *argc = size;
- if (argv) {
- *argv = %new_array(size + 1, char*);
- for (; i < size; ++i) {
- PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i);
- char *cptr = 0; size_t sz = 0; int alloc = 0;
- res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc);
- if (SWIG_IsOK(res)) {
- if (cptr && sz) {
- (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char);
- } else {
- (*argv)[i] = 0;
- }
- } else {
- return SWIG_TypeError;
- }
- }
- (*argv)[i] = 0;
- if (owner) *owner = 1;
- } else {
- for (; i < size; ++i) {
- PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i);
- res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0);
- if (!SWIG_IsOK(res)) return SWIG_TypeError;
- }
- if (owner) *owner = 0;
- }
- return SWIG_OK;
- } else {
- return SWIG_TypeError;
- }
- } else {
- /* seems dangerous, but the user asked for it... */
- size_t i = 0;
- if (argv) { while (*argv[i] != 0) ++i;}
- if (argc) *argc = i;
- if (owner) *owner = 0;
- return SWIG_OK;
- }
-}
-}
-
-/*
- This typemap works with either a char **, a python list or a python
- tuple
- */
-
-%typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) {
- res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner);
- if (!SWIG_IsOK(res)) {
- $1 = 0; $2 = 0;
- %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum);
- } else {
- $1 = %static_cast(argc,$1_ltype);
- $2 = %static_cast(argv, $2_ltype);
- }
-}
-
-%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) {
- int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0);
- $1 = SWIG_IsOK(res);
-}
-
-%typemap(freearg,noblock=1) (int ARGC, char **ARGV) {
- if (owner$argnum) {
- size_t i = argc$argnum;
- while (i) {
- %delete_array(argv$argnum[--i]);
- }
- %delete_array(argv$argnum);
- }
-}
-
diff --git a/Python/classwrapper.i b/Python/classwrapper.i
deleted file mode 100644
index 8450146ee..000000000
--- a/Python/classwrapper.i
+++ /dev/null
@@ -1,282 +0,0 @@
-%{
-
-#include <WarpX.H>
-
-using namespace amrex;
-
-%}
-
-%inline %{
- std::ifstream & open_ifstream(const char *filename) {
- std::ifstream *infile = new std::ifstream(filename);
- return *infile;
- }
-%}
-
-%inline %{
- std::ofstream & open_ofstream(const char *filename) {
- std::ofstream *outfile = new std::ofstream(filename);
- return *outfile;
- }
-%}
-
-%inline %{
- void close_ofstream(std::ofstream& str) {
- str.close();
- }
-%}
-
-%inline %{
- void close_ifstream(std::ifstream & str) {
- str.close();
- }
-%}
-
-%include <std_string.i>
-%rename(__str__) display;
-
-%include "../../amrex/Src/Base/AMReX_Array.H"
-
-%extend amrex::Array {
- T& __getitem__ (size_t i)
- {
- BL_ASSERT(i >= 0);
- BL_ASSERT(i < self->size());
- return self->std::vector<T>::operator[](i);
- }
-
- //
- // Same as above, except acts on const Array's.
- //
- const T& __getitem__ (size_t i) const
- {
- BL_ASSERT(i >= 0);
- BL_ASSERT(i < self->size());
- return self->std::vector<T>::operator[](i);
- }
-}
-
-// This is needed so that swig knows the amrex::Real is just a float or double
-%include "../../amrex/Src/Base/AMReX_REAL.H"
-
-%template(arrayReal) amrex::Array<amrex::Real>;
-%template(arrayInt) amrex::Array<int>;
-%template(arrayGeometry) amrex::Array<amrex::Geometry>;
-
-%extend amrex::Array<amrex::Real> {
- PyObject *get_real() {
- // Get the data as a writeable numpy array, directly accessing the memory.
- PyObject *arr = 0;
- npy_intp dims[1];
- dims[0] = self->std::vector<amrex::Real>::size();
- arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_DOUBLE), 1, dims, NULL,
- self->dataPtr(), NPY_FORTRANORDER|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
-}
-%extend amrex::Array<int> {
- PyObject *get_int() {
- // Get the data as a writeable numpy array, directly accessing the memory.
- PyObject *arr = 0;
- npy_intp dims[1];
- dims[0] = self->std::vector<int>::size();
- arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_INT), 1, dims, NULL,
- self->dataPtr(), NPY_FORTRANORDER|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
-}
-
-// This is needed by swig to define the macro D_DECL when including AMReX_IntVect.H
-%include "../../amrex/Src/Base/AMReX_SPACE.H"
-
-// This include can only be done with the modified AMReX_IntVect.H file that hides the ref-qualifiers from swig.
-%include "../../amrex/Src/Base/AMReX_IntVect.H"
-// Save this code, which is needed if AMReX_IntVect.H cannot be included.
-// AMReX_IntVect.H uses ref-qualifiers in the lines setting up getVect that cannot be parsed by swig.
-/*
-class amrex::IntVect {
-public:
-
- IntVect(int i, int j, int k);
- IntVect(const amrex::IntVect& rhs);
-
- IntVect& shift(int coord, int s);
-
- // static functions
- static const amrex::IntVect& TheZeroVector();
- static const amrex::IntVect& TheUnitVector();
- static const amrex::IntVect& TheNodeVector();
- static const amrex::IntVect& TheCellVector();
-};
-*/
-
-%extend amrex::IntVect {
- //void writeOn(std::ofstream *os){
- // *os << *self;
- //}
- //void read(std::ifstream* ifs){
- // *ifs >> *self;
- //}
- int __getitem__(int index){
- if (index < 0 || index >= BL_SPACEDIM) {
- // SWIG_SetErrorMsg(PyExc_IndexError,"Index out of bounds\n");
- return 0;
- }
- return (*self)[index];
- }
- int __len__() volatile { return BL_SPACEDIM; }
- void __setitem__(int index,int val){
- if (index < 0 || index >= BL_SPACEDIM) {
- //SWIG_SetErrorMsg(PyExc_IndexError,"Index out of bounds\n");
- } else {
- (*self).setVal(index,val);
- }
- }
- int __cmp__(const amrex::IntVect* other){
- if( (*self) == (*other) ) {
- return 0;
- }
- if( (*self) <= (*other) ) {
- return -1;
- }
- return 1;
- }
- PyObject *get() {
- PyObject *arr = 0;
- npy_intp dims[1];
- dims[0] = BL_SPACEDIM;
- arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_INT), 1, dims, NULL,
- self->getVect(), NPY_FORTRANORDER|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
-
- //std::string display() {
- // std::ostringstream str;
- // str << *self;
- // return str.str();
- //}
-}
-
-//%include "../../amrex/Src/Base/AMReX_Box.H"
-%include "../../amrex/Src/Base/AMReX_BaseFab.H"
-
-%template(BaseFabReal) amrex::BaseFab<amrex::Real>;
-
-%extend amrex::BaseFab<amrex::Real> {
- PyObject * get(size_t n=0) {
- PyObject *arr = 0;
- npy_intp dims[BL_SPACEDIM];
- amrex::IntVect size = self->box().size();
- dims[0] = size[0];
- dims[1] = size[1];
- dims[2] = size[2];
- arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_DOUBLE), BL_SPACEDIM, dims, NULL,
- self->dataPtr(n), NPY_FORTRANORDER|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
-}
-
-//%include "../../amrex/Src/Base/AMReX_FArrayBox.H"
-//%include "../../amrex/Src/Base/AMReX_BoxArray.H"
-
-%include "../../amrex/Src/Base/AMReX_FabArray.H"
-
-%extend amrex::FabArray {
- FAB& __getitem__ (size_t i)
- {
- BL_ASSERT(i >= 0);
- BL_ASSERT(i < self->size());
- return self->get(i);
- }
-
- //
- // Same as above, except acts on const Array's.
- //
- const FAB& __getitem__ (size_t i) const
- {
- BL_ASSERT(i >= 0);
- BL_ASSERT(i < self->size());
- return self->get(i);
- }
-}
-
-%template(FabArrayFArrayBox) amrex::FabArray< amrex::FArrayBox >;
-
-%include "../../amrex/Src/Base/AMReX_MultiFab.H"
-
-%template(arrayMultifab) amrex::Array< std::unique_ptr<amrex::MultiFab> >;
-%template(arrayarrayMultifab) amrex::Array<amrex::Array< std::unique_ptr<amrex::MultiFab> > >;
-
-#if (BL_SPACEDIM > 2)
-// GetDLogA is only defined with BL_SPACEDIM <= 2
-%ignore GetDLogA;
-#endif
-
-%include "../../amrex/Src/Base/AMReX_Geometry.H"
-
-%template(arrayBoxArray) amrex::Array<amrex::BoxArray>;
-
-%include "../../amrex/Src/Particle/AMReX_Particles.H"
-
-// Becuase of an apparent problem in swig, the macro around the wrapping of tile_size gives an error during compilation
-%ignore tile_size;
-
-// Swig doesn't handle the unique_ptr return value causing an error during compilation
-%ignore GetChargeDensity;
-
-// Wrapping WarpXParIter fails since swig doesn't handle the alias SoA properly causing an error during compilation
-%ignore WarpXParIter;
-
-%template("WarpXParticleContainerBase") amrex::ParticleContainer<0,0,PIdx::nattribs>;
-
-%include "../Source/ParticleContainer.H"
-%include "../Source/WarpXParticleContainer.H"
-
-%extend WarpXParticleContainer {
- int getNattribs() {
- return PIdx::nattribs;
- }
- PyObject * getLocations() {
- amrex::Array<amrex::Real> result(0);
- self->GetParticleLocations(result);
- npy_intp dims[2] = {BL_SPACEDIM, self->TotalNumberOfParticles()};
- PyObject *arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_DOUBLE), 2, dims, NULL,
- result.dataPtr(), NPY_ARRAY_F_CONTIGUOUS|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
- PyObject * getData(int start_comp, int num_comp) {
- amrex::Array<amrex::Real> result(0);
- self->GetParticleData(result, start_comp, num_comp);
- npy_intp dims[2] = {num_comp, self->TotalNumberOfParticles()};
- PyObject *arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_DOUBLE), 2, dims, NULL,
- result.dataPtr(), NPY_ARRAY_F_CONTIGUOUS|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
- PyObject * getAllData() {
- int num_comp = PIdx::nattribs;
- amrex::Array<amrex::Real> result(0);
- self->GetParticleData(result, 0, num_comp);
- npy_intp dims[2] = {num_comp, self->TotalNumberOfParticles()};
- PyObject *arr = PyArray_NewFromDescr(&PyArray_Type,
- PyArray_DescrFromType(NPY_DOUBLE), 2, dims, NULL,
- result.dataPtr(), NPY_ARRAY_F_CONTIGUOUS|NPY_ARRAY_WRITEABLE, NULL);
- Py_INCREF(arr);
- return arr;
- }
-};
-
-%include "../../amrex/Src/AmrCore/AMReX_AmrCore.H"
-%include "../Source/WarpX.H"
-
diff --git a/Python/numpy.i b/Python/numpy.i
deleted file mode 100644
index b8fdaeb1f..000000000
--- a/Python/numpy.i
+++ /dev/null
@@ -1,3166 +0,0 @@
-/* -*- 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 <numpy/arrayobject.h>
-%}
-
-/**********************************************************************/
-
-%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_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_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;
- int 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;
- /* Set the Fortran ordered flag */
- 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)
-
-/* ***************************************************************
- * 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 <std_complex.i>
-
-%numpy_typemaps(std::complex<float>, NPY_CFLOAT , int)
-%numpy_typemaps(std::complex<double>, NPY_CDOUBLE, int)
-
-#endif
-
-#endif /* SWIGPYTHON */
diff --git a/Python/pywarpx/AMReX.py b/Python/pywarpx/AMReX.py
index 444df3490..e84c240af 100644
--- a/Python/pywarpx/AMReX.py
+++ b/Python/pywarpx/AMReX.py
@@ -8,7 +8,9 @@ from .Langmuirwave import langmuirwave
from .Interpolation import interpolation
from .Particles import particles
-from . import warpxC
+import ctypes
+from ._libwarpx import libwarpx
+from ._libwarpx import amrex_init
class AMReX(object):
@@ -22,7 +24,7 @@ class AMReX(object):
argv += interpolation.attrlist()
argv += particles.attrlist()
- warpxC.amrex_init(argv)
+ amrex_init(argv)
def finalize(self, finalize_mpi=1):
- warpxC.amrex_finalize(finalize_mpi)
+ libwarpx.amrex_finalize(finalize_mpi)
diff --git a/Python/pywarpx/PGroup.py b/Python/pywarpx/PGroup.py
index 616141702..bf59d5ce5 100644
--- a/Python/pywarpx/PGroup.py
+++ b/Python/pywarpx/PGroup.py
@@ -1,15 +1,14 @@
import numpy as np
from . import WarpX
-from . import warpxC
+from . import _libwarpx
class PGroup(object):
"""Implements a class that has the same API as a warp ParticleGroup instance.
"""
- def __init__(self):
+ def __init__(self, igroup):
+ self.igroup = igroup
self.ns = 1 # Number of species
- self.npmax = 0 # Size of data arrays
- self.npid = 0 # number of columns for pid.
self.gallot()
@@ -24,10 +23,6 @@ class PGroup(object):
self.sq = np.zeros(self.ns) # Species charge [C]
self.sw = np.zeros(self.ns) # Species weight, (real particles per simulation particles)
- self.ins = np.ones(self.ns, dtype=int) # Index of first particle in species
- self.nps = np.zeros(self.ns, dtype=int) # Number of particles in species
- self.ipmax = np.zeros(self.ns+1, dtype=int) # Max extent within the arrays of each species
-
self.sid = np.arange(self.ns, dtype=int) # Global species index for each species
self.ndts = np.ones(self.ns, dtype=int) # Stride for time step advance for each species
self.ldts = np.ones(self.ns, dtype=int) # (logical type)
@@ -51,152 +46,104 @@ class PGroup(object):
self.zshift = np.zeros(self.ns)
self.gamma_ebcancel_max = np.ones(self.ns) # maximum value allowed for ExB cancellation
- self.gaminv = np.ones(self.npmax) # inverse relativistic gamma factor
- self._xp = np.zeros(self.npmax) # X-positions of particles [m]
- self._yp = np.zeros(self.npmax) # Y-positions of particles [m]
- self._zp = np.zeros(self.npmax) # Z-positions of particles [m]
- self._uxp = np.zeros(self.npmax) # gamma * X-velocities of particles [m/s]
- self._uyp = np.zeros(self.npmax) # gamma * Y-velocities of particles [m/s]
- self._uzp = np.zeros(self.npmax) # gamma * Z-velocities of particles [m/s]
- self._ex = np.zeros(self.npmax) # Ex of particles [V/m]
- self._ey = np.zeros(self.npmax) # Ey of particles [V/m]
- self._ez = np.zeros(self.npmax) # Ez of particles [V/m]
- self._bx = np.zeros(self.npmax) # Bx of particles [T]
- self._by = np.zeros(self.npmax) # By of particles [T]
- self._bz = np.zeros(self.npmax) # Bz of particles [T]
- self._pid = np.zeros((self.npmax, self.npid)) # Particle ID - used for various purposes
-
# --- Temporary fix
gchange = gallot
def allocated(self, name):
- return (getattr(self, name, None) is not None)
+ return True
def addspecies(self):
pass
- def _updatelocations(self):
- warpx = WarpX.warpx.warpx
- mypc = warpx.GetPartContainer()
-
- xplist = []
- yplist = []
- zplist = []
- for ispecie in range(mypc.nSpecies()):
- pc = mypc.GetParticleContainer(ispecie)
- xx = pc.getLocations()
- xplist.append(xx[0,:])
- yplist.append(xx[1,:])
- zplist.append(xx[2,:])
- self.nps[ispecie] = len(xplist[-1])
- if ispecie > 0:
- self.ins[ispecie] = self.ins[ispecie-1] + self.nps[ispecie-1]
- self.ipmax[ispecie+1] = self.ins[ispecie] + self.nps[ispecie] - 1
-
- self._xp = np.concatenate(xplist)
- self._yp = np.concatenate(yplist)
- self._zp = np.concatenate(zplist)
- self.npmax = len(self._xp)
-
- def _updatevelocities(self):
- warpx = WarpX.warpx.warpx
- mypc = warpx.GetPartContainer()
-
- uxplist = []
- uyplist = []
- uzplist = []
- for ispecie in range(mypc.nSpecies()):
- pc = mypc.GetParticleContainer(ispecie)
- vv = pc.getData(0, 3)
- uxplist.append(vv[0,:])
- uyplist.append(vv[1,:])
- uzplist.append(vv[2,:])
- self.nps[ispecie] = len(uxplist[-1])
- if ispecie > 0:
- self.ins[ispecie] = self.ins[ispecie-1] + self.nps[ispecie-1]
- self.ipmax[ispecie+1] = self.ins[ispecie] + self.nps[ispecie] - 1
-
- self._uxp = np.concatenate(uxplist)
- self._uyp = np.concatenate(uyplist)
- self._uzp = np.concatenate(uzplist)
- self.npmax = len(self._xp)
-
- def _updatepids(self):
- warpx = WarpX.warpx.warpx
- mypc = warpx.GetPartContainer()
-
- pidlist = []
- for ispecie in range(mypc.nSpecies()):
- pc = mypc.GetParticleContainer(ispecie)
- self.npid = pc.nAttribs - 3
- vv = pc.getData(3, self.npid)
- pidlist.append(vv)
- self.nps[ispecie] = len(uxplist[-1])
- if ispecie > 0:
- self.ins[ispecie] = self.ins[ispecie-1] + self.nps[ispecie-1]
- self.ipmax[ispecie+1] = self.ins[ispecie] + self.nps[ispecie] - 1
-
- self._pid = np.concatenate(pidlist.T, axis=0)
- self.npmax = self._pid.shape[0]
-
- def getxp(self):
- self._updatelocations()
- return self._xp
+
+ def getnps(self):
+ return np.array([len(self.xp)], dtype='l')
+ nps = property(getnps)
+
+ def getins(self):
+ return np.ones(self.ns, dtype='l')
+ ins = property(getins)
+
+ def getipmax(self):
+ return np.array([0, len(self.xp)], dtype='l')
+ ipmax = property(getipmax)
+
+ def getnpmax(self):
+ return self.nps.sum()
+ npmax = property(getnpmax)
+
+ def getxp(self, js=0):
+ return _libwarpx.get_particle_x(js)[self.igroup]
xp = property(getxp)
- def getyp(self):
- self._updatelocations()
- return self._yp
+ def getyp(self, js=0):
+ return _libwarpx.get_particle_y(js)[self.igroup]
yp = property(getyp)
- def getzp(self):
- self._updatelocations()
- return self._zp
+ def getzp(self, js=0):
+ return _libwarpx.get_particle_z(js)[self.igroup]
zp = property(getzp)
- def getuxp(self):
- self._updatevelocities()
- return self._uxp
+ def getuxp(self, js=0):
+ return _libwarpx.get_particle_ux(js)[self.igroup]
uxp = property(getuxp)
- def getuyp(self):
- self._updatevelocities()
- return self._uyp
+ def getuyp(self, js=0):
+ return _libwarpx.get_particle_uy(js)[self.igroup]
uyp = property(getuyp)
- def getuzp(self):
- self._updatevelocities()
- return self._uzp
+ def getuzp(self, js=0):
+ return _libwarpx.get_particle_uz(js)[self.igroup]
uzp = property(getuzp)
- def getpid(self):
- self._updatepids()
- return self._pid
+ def getpid(self, js=0):
+ return _libwarpx.get_particle_id(js)[self.igroup]
pid = property(getpid)
- def getgaminv(self):
- uxp = self.uxp
- uyp = self.uyp
- uzp = self.uzp
+ def getgaminv(self, js=0):
+ uxp = self.getuxp(js)
+ uyp = self.getuyp(js)
+ uzp = self.getuzp(js)
return sqrt(1. - (uxp**2 + uyp**2 + uzp**2)/warpxC.c**2)
gaminv = property(getgaminv)
- def getex(self):
- return np.zeros(self.npmax)
+ def getex(self, js=0):
+ return _libwarpx.get_particle_Ex(js)[self.igroup]
ex = property(getex)
- def getey(self):
- return np.zeros(self.npmax)
+
+ def getey(self, js=0):
+ return _libwarpx.get_particle_Ey(js)[self.igroup]
ey = property(getey)
- def getez(self):
- return np.zeros(self.npmax)
+
+ def getez(self, js=0):
+ return _libwarpx.get_particle_Ez(js)[self.igroup]
ez = property(getez)
- def getbx(self):
- return np.zeros(self.npmax)
+
+ def getbx(self, js=0):
+ return _libwarpx.get_particle_Bx(js)[self.igroup]
bx = property(getbx)
- def getby(self):
- return np.zeros(self.npmax)
+
+ def getby(self, js=0):
+ return _libwarpx.get_particle_By(js)[self.igroup]
by = property(getby)
- def getbz(self):
- return np.zeros(self.npmax)
+
+ def getbz(self, js=0):
+ return _libwarpx.get_particle_Bz(js)[self.igroup]
bz = property(getbz)
+class PGroups(object):
+ def __init__(self):
+ xall = _libwarpx.get_particle_x(0)
+ self.ngroups = len(xall)
+
+ self._pgroups = []
+ for igroup in range(self.ngroups):
+ self._pgroups.append(PGroup(igroup))
+
+ def __iter__(self):
+ for igroup in range(self.ngroups):
+ yield self._pgroups[igroup]
+
+ def __getitem__(self, key):
+ return self._pgroups[key]
+
diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py
index e9ec7cca4..f0a31f3f9 100644
--- a/Python/pywarpx/WarpX.py
+++ b/Python/pywarpx/WarpX.py
@@ -1,5 +1,5 @@
from .Bucket import Bucket
-from . import warpxC
+from ._libwarpx import libwarpx
class WarpX(Bucket):
"""
@@ -7,21 +7,18 @@ class WarpX(Bucket):
"""
def init(self):
- self.warpx = warpxC.WarpX.GetInstance()
- self.warpx.InitData()
+ libwarpx.warpx_init()
def evolve(self, nsteps=-1):
- self.warpx.Evolve(nsteps)
+ libwarpx.warpx_evolve(nsteps)
def finalize(self):
- warpxC.WarpX.ResetInstance()
+ libwarpx.warpx_finalize()
def getProbLo(self, direction):
- return self.warpx.Geom()[0].ProbLo(direction)
- #return warpxC.warpx_getProbLo(direction)
+ return libwarpx.warpx_getProbLo(direction)
def getProbHi(self, direction):
- return self.warpx.Geom()[0].ProbHi(direction)
- #return warpxC.warpx_getProbHi(direction)
+ return libwarpx.warpx_getProbHi(direction)
warpx = WarpX('warpx')
diff --git a/Python/pywarpx/__init__.py b/Python/pywarpx/__init__.py
index 4a509419e..cf79c65a6 100644
--- a/Python/pywarpx/__init__.py
+++ b/Python/pywarpx/__init__.py
@@ -10,4 +10,6 @@ from .AMReX import AMReX
from .timestepper import TimeStepper
from .PGroup import PGroup
+from .PGroup import PGroups
+from ._libwarpx import add_particles
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
new file mode 100755
index 000000000..5174e018d
--- /dev/null
+++ b/Python/pywarpx/_libwarpx.py
@@ -0,0 +1,524 @@
+# --- This defines the wrapper functions that directly call the underlying compiled routines
+import os
+import sys
+import ctypes
+from ctypes.util import find_library
+import numpy as np
+from numpy.ctypeslib import ndpointer
+
+
+def get_package_root():
+ '''
+ Get the path to the installation location (where libwarpx.so would be installed).
+ '''
+ cur = os.path.abspath(__file__)
+ while True:
+ name = os.path.basename(cur)
+ if name == 'pywarpx':
+ return cur
+ elif not name:
+ return ''
+ cur = os.path.dirname(cur)
+
+libwarpx = ctypes.CDLL(os.path.join(get_package_root(), "libwarpx.so"))
+libc = ctypes.CDLL(find_library('c'))
+
+
+
+libwarpx.warpx_getistep.restype = ctypes.c_int
+libwarpx.warpx_gett_new.restype = ctypes.c_double
+libwarpx.warpx_getdt.restype = ctypes.c_double
+libwarpx.warpx_maxStep.restype = ctypes.c_int
+libwarpx.warpx_stopTime.restype = ctypes.c_double
+libwarpx.warpx_checkInt.restype = ctypes.c_int
+libwarpx.warpx_plotInt.restype = ctypes.c_int
+libwarpx.warpx_finestLevel.restype = ctypes.c_int
+
+
+libwarpx.warpx_EvolveE.argtypes = [ctypes.c_int, ctypes.c_double]
+libwarpx.warpx_EvolveB.argtypes = [ctypes.c_int, ctypes.c_double]
+libwarpx.warpx_FillBoundaryE.argtypes = [ctypes.c_int, ctypes.c_bool]
+libwarpx.warpx_FillBoundaryB.argtypes = [ctypes.c_int, ctypes.c_bool]
+libwarpx.warpx_PushParticlesandDepose.argtypes = [ctypes.c_int, ctypes.c_double]
+libwarpx.warpx_getistep.argtypes = [ctypes.c_int]
+libwarpx.warpx_setistep.argtypes = [ctypes.c_int, ctypes.c_int]
+libwarpx.warpx_gett_new.argtypes = [ctypes.c_int]
+libwarpx.warpx_sett_new.argtypes = [ctypes.c_int, ctypes.c_double]
+libwarpx.warpx_getdt.argtypes = [ctypes.c_int]
+
+
+
+# some useful data structures and typenames
+class Particle(ctypes.Structure):
+ _fields_ = [('x', ctypes.c_double),
+ ('y', ctypes.c_double),
+ ('z', ctypes.c_double),
+ ('id', ctypes.c_int),
+ ('cpu', ctypes.c_int)]
+
+
+p_dtype = np.dtype([('x', 'f8'), ('y', 'f8'), ('z', 'f8'),
+ ('id', 'i4'), ('cpu', 'i4')])
+
+c_double_p = ctypes.POINTER(ctypes.c_double)
+LP_c_char = ctypes.POINTER(ctypes.c_char)
+LP_LP_c_char = ctypes.POINTER(LP_c_char)
+
+# where do I import these? this might only work for CPython...
+PyBuf_READ = 0x100
+PyBUF_WRITE = 0x200
+
+# this is a function for converting a ctypes pointer to a numpy array
+def array1d_from_pointer(pointer, dtype, size):
+ if sys.version_info.major >= 3:
+ buffer_from_memory = ctypes.pythonapi.PyMemoryView_FromMemory
+ buffer_from_memory.argtypes = (ctypes.c_void_p, ctypes.c_int, ctypes.c_int)
+ buffer_from_memory.restype = ctypes.py_object
+ buf = buffer_from_memory(pointer, dtype.itemsize*size, PyBUF_WRITE)
+ else:
+ buffer_from_memory = ctypes.pythonapi.PyBuffer_FromReadWriteMemory
+ buffer_from_memory.restype = ctypes.py_object
+ buf = buffer_from_memory(pointer, dtype.itemsize*size)
+ return np.frombuffer(buf, dtype=dtype, count=size)
+
+
+# set the arg and return types of the wrapped functions
+f = libwarpx.amrex_init
+f.argtypes = (ctypes.c_int, LP_LP_c_char)
+
+f = libwarpx.warpx_getParticleStructs
+f.restype = ctypes.POINTER(ctypes.POINTER(Particle))
+
+f = libwarpx.warpx_getParticleArrays
+f.restype = ctypes.POINTER(c_double_p)
+
+f = libwarpx.warpx_getParticleArrays
+f.restype = ctypes.POINTER(c_double_p)
+
+f = libwarpx.warpx_getEfield
+f.restype = ctypes.POINTER(c_double_p)
+
+f = libwarpx.warpx_getBfield
+f.restype = ctypes.POINTER(c_double_p)
+
+f = libwarpx.warpx_getCurrentDensity
+f.restype = ctypes.POINTER(c_double_p)
+
+f = libwarpx.addNParticles
+f.argtypes = (ctypes.c_int, ctypes.c_int,
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ctypes.c_int,
+ ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
+ ctypes.c_int)
+
+def amrex_init(argv):
+ # --- Construct the ctype list of strings to pass in
+ argc = len(argv)
+ argvC = (LP_c_char * (argc+1))()
+ for i, arg in enumerate(argv):
+ enc_arg = arg.encode('utf-8')
+ argvC[i] = ctypes.create_string_buffer(enc_arg)
+
+ libwarpx.amrex_init(argc, argvC)
+
+def add_particles(species_number,
+ x, y, z, ux, uy, uz, attr, unique_particles):
+ '''
+
+ A function for adding particles to the WarpX simulation.
+
+ Parameters
+ ----------
+
+ species_number : the species to add the particle to
+ x, y, z : numpy arrays of the particle positions
+ ux, uy, uz : numpy arrays of the particle momenta
+ attr : a 2D numpy array with the particle attributes
+ unique_particles : whether the particles are unique or duplicated on
+ several processes
+
+ '''
+ libwarpx.addNParticles(species_number, x.size,
+ x, y, z, ux, uy, uz,
+ attr.shape[1], attr, unique_particles)
+
+def get_particle_structs(species_number):
+ '''
+
+ This returns a list of numpy arrays containing the particle struct data
+ on each tile for this process. The particle data is represented as a structured
+ numpy array and contains the particle 'x', 'y', 'z', 'id', and 'cpu'.
+
+ The data for the numpy arrays are not copied, but share the underlying
+ memory buffer with WarpX. The numpy arrays are fully writeable.
+
+ Parameters
+ ----------
+
+ species_number : the species id that the data will be returned for
+
+ Returns
+ -------
+
+ A List of numpy arrays.
+
+ '''
+
+ particles_per_tile = ctypes.POINTER(ctypes.c_int)()
+ num_tiles = ctypes.c_int(0)
+ data = libwarpx.warpx_getParticleStructs(0, ctypes.byref(num_tiles),
+ ctypes.byref(particles_per_tile))
+
+ particle_data = []
+ for i in range(num_tiles.value):
+ arr = array1d_from_pointer(data[i], p_dtype, particles_per_tile[i])
+ particle_data.append(arr)
+
+ libc.free(particles_per_tile)
+ libc.free(data)
+ return particle_data
+
+
+def get_particle_arrays(species_number, comp):
+ '''
+
+ This returns a list of numpy arrays containing the particle array data
+ on each tile for this process.
+
+ The data for the numpy arrays are not copied, but share the underlying
+ memory buffer with WarpX. The numpy arrays are fully writeable.
+
+ Parameters
+ ----------
+
+ species_number : the species id that the data will be returned for
+ comp : the component of the array data that will be returned.
+
+ Returns
+ -------
+
+ A List of numpy arrays.
+
+ '''
+
+ particles_per_tile = ctypes.POINTER(ctypes.c_int)()
+ num_tiles = ctypes.c_int(0)
+ data = libwarpx.warpx_getParticleArrays(0, comp, ctypes.byref(num_tiles),
+ ctypes.byref(particles_per_tile))
+
+ particle_data = []
+ for i in range(num_tiles.value):
+ arr = np.ctypeslib.as_array(data[i], (particles_per_tile[i],))
+ arr.setflags(write=1)
+ particle_data.append(arr)
+
+ libc.free(particles_per_tile)
+ libc.free(data)
+ return particle_data
+
+
+def get_particle_x(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle 'x'
+ positions on each tile.
+
+ '''
+ structs = get_particle_structs(species_number)
+ return [struct['x'] for struct in structs]
+
+
+def get_particle_y(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle 'y'
+ positions on each tile.
+
+ '''
+ structs = get_particle_structs(species_number)
+ return [struct['y'] for struct in structs]
+
+
+def get_particle_z(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle 'z'
+ positions on each tile.
+
+ '''
+ structs = get_particle_structs(species_number)
+ return [struct['z'] for struct in structs]
+
+
+def get_particle_id(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle 'z'
+ positions on each tile.
+
+ '''
+ structs = get_particle_structs(species_number)
+ return [struct['id'] for struct in structs]
+
+
+def get_particle_cpu(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle 'z'
+ positions on each tile.
+
+ '''
+ structs = get_particle_structs(species_number)
+ return [struct['cpu'] for struct in structs]
+
+
+def get_particle_weight(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ weight on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 0)
+
+
+def get_particle_ux(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ x momentum on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 1)
+
+
+def get_particle_uy(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ y momentum on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 2)
+
+
+def get_particle_uz(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ z momentum on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 3)
+
+
+def get_particle_Ex(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ x electric field on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 4)
+
+
+def get_particle_Ey(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ y electric field on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 5)
+
+
+def get_particle_Ez(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ z electric field on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 6)
+
+
+def get_particle_Bx(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ x magnetic field on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 7)
+
+
+def get_particle_By(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ y magnetic field on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 8)
+
+
+def get_particle_Bz(species_number):
+ '''
+
+ Return a list of numpy arrays containing the particle
+ z magnetic field on each tile.
+
+ '''
+
+ return get_particle_arrays(species_number, 9)
+
+
+def get_mesh_electric_field(level, direction, include_ghosts=True):
+ '''
+
+ This returns a list of numpy arrays containing the mesh electric field
+ data on each grid for this process.
+
+ The data for the numpy arrays are not copied, but share the underlying
+ memory buffer with WarpX. The numpy arrays are fully writeable.
+
+ Parameters
+ ----------
+
+ level : the AMR level to get the data for
+ direction : the component of the data you want
+ include_ghosts : whether to include ghost zones or not
+
+ Returns
+ -------
+
+ A List of numpy arrays.
+
+ '''
+
+ shapes = ctypes.POINTER(ctypes.c_int)()
+ size = ctypes.c_int(0)
+ ngrow = ctypes.c_int(0)
+ data = libwarpx.warpx_getEfield(0, direction,
+ ctypes.byref(size), ctypes.byref(ngrow),
+ ctypes.byref(shapes))
+ ng = ngrow.value
+ grid_data = []
+ for i in range(size.value):
+ shape=(shapes[3*i+0], shapes[3*i+1], shapes[3*i+2])
+ arr = np.ctypeslib.as_array(data[i], shape)
+ arr.setflags(write=1)
+ if include_ghosts:
+ grid_data.append(arr)
+ else:
+ grid_data.append(arr[ng:-ng,ng:-ng,ng:-ng])
+
+ libc.free(shapes)
+ libc.free(data)
+ return grid_data
+
+
+def get_mesh_magnetic_field(level, direction, include_ghosts=True):
+ '''
+
+ This returns a list of numpy arrays containing the mesh magnetic field
+ data on each grid for this process.
+
+ The data for the numpy arrays are not copied, but share the underlying
+ memory buffer with WarpX. The numpy arrays are fully writeable.
+
+ Parameters
+ ----------
+
+ level : the AMR level to get the data for
+ direction : the component of the data you want
+ include_ghosts : whether to include ghost zones or not
+
+ Returns
+ -------
+
+ A List of numpy arrays.
+
+ '''
+
+ shapes = ctypes.POINTER(ctypes.c_int)()
+ size = ctypes.c_int(0)
+ ngrow = ctypes.c_int(0)
+ data = libwarpx.warpx_getBfield(0, direction,
+ ctypes.byref(size), ctypes.byref(ngrow),
+ ctypes.byref(shapes))
+ ng = ngrow.value
+ grid_data = []
+ for i in range(size.value):
+ shape=(shapes[3*i+0], shapes[3*i+1], shapes[3*i+2])
+ arr = np.ctypeslib.as_array(data[i], shape)
+ arr.setflags(write=1)
+ if include_ghosts:
+ grid_data.append(arr)
+ else:
+ grid_data.append(arr[ng:-ng,ng:-ng,ng:-ng])
+
+ libc.free(shapes)
+ libc.free(data)
+ return grid_data
+
+
+def get_mesh_current_density(level, direction, include_ghosts=True):
+ '''
+
+ This returns a list of numpy arrays containing the mesh current density
+ data on each grid for this process.
+
+ The data for the numpy arrays are not copied, but share the underlying
+ memory buffer with WarpX. The numpy arrays are fully writeable.
+
+ Parameters
+ ----------
+
+ level : the AMR level to get the data for
+ direction : the component of the data you want
+ include_ghosts : whether to include ghost zones or not
+
+ Returns
+ -------
+
+ A List of numpy arrays.
+
+ '''
+
+ shapes = ctypes.POINTER(ctypes.c_int)()
+ size = ctypes.c_int(0)
+ ngrow = ctypes.c_int(0)
+ data = libwarpx.warpx_getCurrentDensity(0, direction,
+ ctypes.byref(size), ctypes.byref(ngrow),
+ ctypes.byref(shapes))
+ ng = ngrow.value
+ grid_data = []
+ for i in range(size.value):
+ shape=(shapes[3*i+0], shapes[3*i+1], shapes[3*i+2])
+ arr = np.ctypeslib.as_array(data[i], shape)
+ arr.setflags(write=1)
+ if include_ghosts:
+ grid_data.append(arr)
+ else:
+ grid_data.append(arr[ng:-ng,ng:-ng,ng:-ng])
+
+ libc.free(shapes)
+ libc.free(data)
+ return grid_data
+
+
diff --git a/Python/pywarpx/timestepper.py b/Python/pywarpx/timestepper.py
index 71787c7a4..1e3519dcc 100644
--- a/Python/pywarpx/timestepper.py
+++ b/Python/pywarpx/timestepper.py
@@ -2,18 +2,18 @@ import warp
from warp import top
from warp import w3d
-from . import WarpX
+from ._libwarpx import libwarpx
class TimeStepper(object):
+ def step(self, nsteps=1):
+ for i in range(nsteps):
+ self.onestep()
def onestep(self):
- # --- A reference to the instance of the WarpX class
- warpx = WarpX.warpx.warpx
- mypc = warpx.GetPartContainer()
- self.cur_time = warpx.gett_new(0)
- self.istep = warpx.getistep(0)
+ self.cur_time = libwarpx.warpx_gett_new(0)
+ self.istep = libwarpx.warpx_getistep(0)
#if mpi.rank == 0:
print "\nSTEP %d starts ..."%(self.istep + 1)
@@ -21,53 +21,52 @@ class TimeStepper(object):
#if (ParallelDescriptor::NProcs() > 1)
# if (okToRegrid(step)) RegridBaseLevel();
- warpx.ComputeDt()
- dt = warpx.getdt(0)
+ libwarpx.warpx_ComputeDt()
+ dt = libwarpx.warpx_getdt(0)
# --- Advance level 0 by dt
lev = 0
# --- At the beginning, we have B^{n-1/2} and E^{n}.
# --- Particles have p^{n-1/2} and x^{n}.
- warpx.EvolveB(lev, 0.5*dt) # We now B^{n}
+ libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n}
- warpx.FillBoundaryE(lev, False)
- warpx.FillBoundaryB(lev, False)
+ libwarpx.warpx_FillBoundaryE(lev, False)
+ libwarpx.warpx_FillBoundaryB(lev, False)
# --- Evolve particles to p^{n+1/2} and x^{n+1}
# --- Depose current, j^{n+1/2}
- warpx.PushParticlesandDepose(lev, self.cur_time)
+ libwarpx.warpx_PushParticlesandDepose(lev, self.cur_time)
- mypc.Redistribute() # Redistribute particles
+ libwarpx.mypc_Redistribute() # Redistribute particles
- warpx.EvolveB(lev, 0.5*dt) # We now B^{n+1/2}
+ libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n+1/2}
- warpx.FillBoundaryB(lev, True)
+ libwarpx.warpx_FillBoundaryB(lev, True)
- warpx.EvolveE(lev, dt) # We now have E^{n+1}
+ libwarpx.warpx_EvolveE(lev, dt) # We now have E^{n+1}
self.istep += 1
self.cur_time += dt
- warpx.MoveWindow();
+ libwarpx.warpx_MoveWindow();
#if mpi.rank == 0:
print "STEP %d ends. TIME = %e DT = %e"%(self.istep, self.cur_time, dt)
# --- Sync up time
- for i in range(warpx.finestLevel()+1):
- warpx.sett_new(i, self.cur_time)
- warpx.setistep(i, self.istep)
+ for i in range(libwarpx.warpx_finestLevel()+1):
+ libwarpx.warpx_sett_new(i, self.cur_time)
+ libwarpx.warpx_setistep(i, self.istep)
- max_time_reached = ((self.cur_time >= warpx.stopTime() - 1.e-6*dt) or (self.istep >= warpx.maxStep()))
+ max_time_reached = ((self.cur_time >= libwarpx.warpx_stopTime() - 1.e-6*dt) or (self.istep >= libwarpx.warpx_maxStep()))
- if warpx.plotInt() > 0 and (self.istep+1)%warpx.plotInt() == 0 or max_time_reached:
- warpx.WritePlotFile()
-
- if warpx.checkInt() > 0 and (self.istep+1)%warpx.plotInt() == 0 or max_time_reached:
- warpx.WriteCheckPointFile()
+ if libwarpx.warpx_plotInt() > 0 and (self.istep+1)%libwarpx.warpx_plotInt() == 0 or max_time_reached:
+ libwarpx.warpx_WritePlotFile()
+ if libwarpx.warpx_checkInt() > 0 and (self.istep+1)%libwarpx.warpx_plotInt() == 0 or max_time_reached:
+ libwarpx.warpx_WriteCheckPointFile()
@@ -80,6 +79,7 @@ class TimeStepper(object):
+# --- This is not used
class TimeStepperFromPICSAR(object):
def __init__(self, package=None, solver=None, l_debug=False):
diff --git a/Python/setup.py b/Python/setup.py
index 3c33a6b3a..20e7c5d9f 100644
--- a/Python/setup.py
+++ b/Python/setup.py
@@ -4,48 +4,11 @@
setup.py file for WarpX
"""
-import os
-from distutils.core import setup, Extension
-import platform
-import numpy
-
-try:
- numpy_include = numpy.get_include()
-except AttributeError:
- numpy_include = numpy.get_numpy_include()
-
-amrex_home = os.environ.get('AMREX_HOME', '../../amrex')
-amrex_includes = ['Src/Base',
- 'Src/Particle',
- 'Src/Boundary',
- 'Src/AmrCore',
- 'Tools/scripts']
-amrex_includes = [os.path.join(amrex_home, ii) for ii in amrex_includes]
-
-include_dirs = [numpy_include, '../Source'] + amrex_includes
-
-definesstring = os.environ.get('DEFINES','')
-defines = definesstring.split(' ')
-
-#cpp11_flags = [] #['-std=c++11']
-#if platform.system() == "Darwin":
-# macosx_deployment_target = platform.mac_ver()[0]
-# os.environ['MACOSX_DEPLOYMENT_TARGET'] = macosx_deployment_target
-# cpp11_flags.append("-stdlib=libc++")
-
-example_module = Extension('pywarpx._warpxC',
- swig_opts=['-c++', '-outdir', 'pywarpx'] + defines,
- sources=['warpxC.i'],
- library_dirs=['.'],
- libraries=['warpx'],
- include_dirs = include_dirs,
- #define_macros = [('BL_USE_MPI','1'), ('BL_SPACEDIM','3'), ('BL_FORT_USE_UNDERSCORE','1'), ('USE_PARTICLES', None)],
- #extra_compile_args = cpp11_flags,
- )
+from distutils.core import setup
setup (name = 'pywarpx',
packages = ['pywarpx'],
package_dir = {'pywarpx':'pywarpx'},
description = """Wrapper of WarpX""",
- ext_modules = [example_module],
+ package_data = {'pywarpx' : ['libwarpx.so']},
)
diff --git a/Python/warpxC.i b/Python/warpxC.i
deleted file mode 100644
index 6865a7fb0..000000000
--- a/Python/warpxC.i
+++ /dev/null
@@ -1,53 +0,0 @@
-%module warpxC
-
-%{
-#include <WarpXConst.H>
-#include <WarpXWrappers.h>
-
-#define SWIG_FILE_WITH_INIT
-#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
-%}
-%include "numpy.i"
-%init %{
-import_array();
-%}
-
-%include "../Source/WarpXConst.H"
-
-// For amrex_init(int argc, char *argv[]);
-%include <argcargv.i>
-%apply (int ARGC, char **ARGV) { (int argc, char *argv[]) }
-
-%rename (addNParticles) wrapped_addNParticles;
-%ignore addNParticles;
-
-%include "../Source/WarpXWrappers.h"
-
-%apply (int DIM1, double* IN_ARRAY1) {(int lenx, double* x),
- (int leny, double* y),
- (int lenz, double* z),
- (int lenvx, double* vx),
- (int lenvy, double* vy),
- (int lenvz, double* vz)}
-%apply (int DIM1, int DIM2, double* IN_FARRAY2 ) {(int lena, int nattr, double* attr)} // Note Fortran ordering
-
-%exception wrapped_addNParticles {
- $action
- if (PyErr_Occurred()) SWIG_fail;
-}
-
-%inline %{
-void wrapped_addNParticles(int speciesnumber, int lenx, double* x, int leny, double* y, int lenz, double* z,
- int lenvx, double* vx, int lenvy, double* vy, int lenvz, double* vz,
- int lena, int nattr, double* attr, int uniqueparticles) {
- if (lenx != leny || lenx != lenz || lenx != lenvx || lenx != lenvy || lenx != lenvz || lenx != lena ) {
- PyErr_Format(PyExc_ValueError,
- "Lengths of arrays must be the same, (%d, %d, %d, %d, %d, %d, %d)",
- lenx, leny, lenz, lenvx, lenvy, lenvz, lena);
- return;
- }
- addNParticles(speciesnumber, lenx, x, y, z, vx, vy, vz, nattr, attr, uniqueparticles);
-}
-%}
-
-%include classwrapper.i