summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-07-29 18:26:55 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-07-29 18:26:55 -0600
commitb307a8a5729e5e18fa8a7ff56892947fc2d2eb79 (patch)
treecf1bb60e0b31b8a1b01b93af112056473503341b /doc
parent32206dd79cafdce87cfb0db91903084c2fe2e473 (diff)
parentf70632f74f7b0feb9d78aff62eb9eebbb6a502ba (diff)
downloadnumpy-b307a8a5729e5e18fa8a7ff56892947fc2d2eb79.tar.gz
Merge branch 'numpy-swig' into gh-3451
* numpy-swig: Added more mentions of the SuperTensor tests and corrected the number of typemaps and tests (currently 1427 unit tests passed with 'make test': 372+324+324+324+40+19+24) Added mention of the SuperTensor tests in the README file Removed 'static' keyword from pyfragments.swg altoghether. I've had the following errors In function ‘SWIG_AsVal_long’: error: initialiser element is not constant In function ‘SWIG_AsVal_unsigned_SS_long’: error: initialiser element is not constant, BOTH in Windows/MinGW and Linux when compiling with gcc Added tests for 4D tensors. Now using a consistant cubes,slices,rows,columns index order everywhere. cleaned-up loop indexes in Tensor.cxx cosmetic changes to numpy.i Fixed the capsule / cobject memory destructor. Added types to deal with lists of arrays and lists of tensors as input and inplace types. removed the note about testResize1 failing in testArray.py fixed the testResize1 test in testArray.py -- Changed order of the resize arguments in Array2.h and replaced len(XXXnumpyarray) with XXXnumpyarray.size Minor adjustments to numpy.i Updated numpy.i testing documentation Updated the numpy.i documentation Initialize all DATA_TYPE* data_temp variables to NULL Added Egor's ARGOUTVIEWM_ARRAY3 typemaps Re-instated a Python 3 fix Removed doc from list of sub-directories Upgrade numpy.i Got rid of a unit test Conflicts: doc/sphinxext doc/swig/test/testFortran.py
Diffstat (limited to 'doc')
-rw-r--r--doc/source/reference/swig.interface-file.rst200
-rw-r--r--doc/source/reference/swig.testing.rst14
-rw-r--r--doc/swig/Makefile2
-rw-r--r--doc/swig/README60
-rw-r--r--doc/swig/numpy.i1836
-rw-r--r--doc/swig/pyfragments.swg4
-rw-r--r--doc/swig/test/Array.i5
-rw-r--r--doc/swig/test/Array2.h2
-rw-r--r--doc/swig/test/SuperTensor.cxx144
-rw-r--r--doc/swig/test/SuperTensor.h53
-rw-r--r--doc/swig/test/SuperTensor.i50
-rw-r--r--doc/swig/test/Tensor.cxx80
-rw-r--r--doc/swig/test/Tensor.h16
-rw-r--r--doc/swig/test/Tensor.i8
-rwxr-xr-xdoc/swig/test/testArray.py12
-rw-r--r--doc/swig/test/testFortran.py21
-rw-r--r--doc/swig/test/testSuperTensor.py388
17 files changed, 2591 insertions, 304 deletions
diff --git a/doc/source/reference/swig.interface-file.rst b/doc/source/reference/swig.interface-file.rst
index 0a358bd6e..8ef6c80ab 100644
--- a/doc/source/reference/swig.interface-file.rst
+++ b/doc/source/reference/swig.interface-file.rst
@@ -49,13 +49,13 @@ internally convert it to a NumPy array before extracting its data
and length.
`SWIG`_ allows these types of conversions to be defined via a
-mechanism called typemaps. This document provides information on how
-to use ``numpy.i``, a `SWIG`_ interface file that defines a series of
-typemaps intended to make the type of array-related conversions
+mechanism called *typemaps*. This document provides information on
+how to use ``numpy.i``, a `SWIG`_ interface file that defines a series
+of typemaps intended to make the type of array-related conversions
described above relatively simple to implement. For example, suppose
that the ``rms`` function prototype defined above was in a header file
-named ``rms.h``. To obtain the Python interface discussed above,
-your `SWIG`_ interface file would need the following::
+named ``rms.h``. To obtain the Python interface discussed above, your
+`SWIG`_ interface file would need the following::
%{
#define SWIG_FILE_WITH_INIT
@@ -76,16 +76,16 @@ either by type or by type and name. We will refer to such lists as
*signatures*. One of the many typemaps defined by ``numpy.i`` is used
above and has the signature ``(double* IN_ARRAY1, int DIM1)``. The
argument names are intended to suggest that the ``double*`` argument
-is an input array of one dimension and that the ``int`` represents
-that dimension. This is precisely the pattern in the ``rms``
+is an input array of one dimension and that the ``int`` represents the
+size of that dimension. This is precisely the pattern in the ``rms``
prototype.
Most likely, no actual prototypes to be wrapped will have the argument
-names ``IN_ARRAY1`` and ``DIM1``. We use the ``%apply`` directive to
-apply the typemap for one-dimensional input arrays of type ``double``
-to the actual prototype used by ``rms``. Using ``numpy.i``
-effectively, therefore, requires knowing what typemaps are available
-and what they do.
+names ``IN_ARRAY1`` and ``DIM1``. We use the `SWIG`_ ``%apply``
+directive to apply the typemap for one-dimensional input arrays of
+type ``double`` to the actual prototype used by ``rms``. Using
+``numpy.i`` effectively, therefore, requires knowing what typemaps are
+available and what they do.
A `SWIG`_ interface file that includes the `SWIG`_ directives given
above will produce wrapper code that looks something like::
@@ -169,8 +169,7 @@ Using numpy.i
The ``numpy.i`` file is currently located in the ``numpy/docs/swig``
sub-directory under the ``numpy`` installation directory. Typically,
you will want to copy it to the directory where you are developing
-your wrappers. If it is ever adopted by `SWIG`_ developers, then it
-will be installed in a standard place where `SWIG`_ can find it.
+your wrappers.
A simple module that only uses a single `SWIG`_ interface file should
include the following::
@@ -232,7 +231,7 @@ could be any of the C data types listed above, and ``DIM_TYPE`` which
should be one of the many types of integers.
The typemap signatures are largely differentiated on the name given to
-the buffer pointer. Names with ``FARRAY`` are for FORTRAN-ordered
+the buffer pointer. Names with ``FARRAY`` are for Fortran-ordered
arrays, and names with ``ARRAY`` are for C-ordered (or 1D arrays).
Input Arrays
@@ -266,6 +265,14 @@ of array. The input array signatures are
* ``( DATA_TYPE* IN_FARRAY3, int DIM1, int DIM2, int DIM3 )``
* ``( int DIM1, int DIM2, int DIM3, DATA_TYPE* IN_FARRAY3 )``
+4D:
+
+ * ``(DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])``
+ * ``(DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)``
+ * ``(DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)``
+ * ``(DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)``
+ * ``(DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)``
+
The first signature listed, ``( DATA_TYPE IN_ARRAY[ANY] )`` is for
one-dimensional arrays with hard-coded dimensions. Likewise,
``( DATA_TYPE IN_ARRAY2[ANY][ANY] )`` is for two-dimensional arrays
@@ -302,6 +309,14 @@ signatures are
* ``( DATA_TYPE* INPLACE_FARRAY3, int DIM1, int DIM2, int DIM3 )``
* ``( int DIM1, int DIM2, int DIM3, DATA_TYPE* INPLACE_FARRAY3 )``
+4D:
+
+ * ``(DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])``
+ * ``(DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)``
+ * ``(DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)``
+ * ``(DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)``
+ * ``(DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)``
+
These typemaps now check to make sure that the ``INPLACE_ARRAY``
arguments use native byte ordering. If not, an exception is raised.
@@ -335,6 +350,10 @@ argument. The argout signatures are
* ``( DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY] )``
+4D:
+
+ * ``( DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY] )``
+
These are typically used in situations where in C/C++, you would
allocate a(n) array(s) on the heap, and call the function to fill the
array(s) values. In Python, the arrays are allocated for you and
@@ -345,8 +364,8 @@ or 3D. This is because of a quirk with the `SWIG`_ typemap syntax and
cannot be avoided. Note that for these types of 1D typemaps, the
Python function will take a single argument representing ``DIM1``.
-Argoutview Arrays
-`````````````````
+Argout View Arrays
+``````````````````
Argoutview arrays are for when your C code provides you with a view of
its internal data and does not require any memory to be allocated by
@@ -354,7 +373,7 @@ the user. This can be dangerous. There is almost no way to guarantee
that the internal data from the C code will remain in existence for
the entire lifetime of the NumPy array that encapsulates it. If
the user destroys the object that provides the view of the data before
-destroying the NumPy array, then using that array my result in bad
+destroying the NumPy array, then using that array may result in bad
memory references or segmentation faults. Nevertheless, there are
situations, working with large data sets, where you simply have no
other choice.
@@ -383,9 +402,50 @@ typemap signatures are therefore
* ``( DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)``
* ``( DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)``
+4D:
+
+ * ``(DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)``
+ * ``(DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)``
+
Note that arrays with hard-coded dimensions are not supported. These
cannot follow the double pointer signatures of these typemaps.
+Memory Managed Argout View Arrays
+`````````````````````````````````
+
+A recent addition to ``numpy.i`` are typemaps that permit argout
+arrays with views into memory that is managed. See the discussion `here
+<http://blog.enthought.com/python/numpy-arrays-with-pre-allocated-memory>`_.
+
+1D:
+
+ * ``(DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)``
+ * ``(DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)``
+
+2D:
+
+ * ``(DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)``
+ * ``(DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)``
+
+3D:
+
+ * ``(DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)``
+ * ``(DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)``
+
+4D:
+
+ * ``(DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)``
+ * ``(DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)``
+ * ``(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)``
+
+
Output Arrays
`````````````
@@ -556,10 +616,34 @@ Macros
Evaluates to the ``i``-th dimension size of ``a``, assuming ``a``
can be cast to a ``PyArrayObject*``.
+ **array_strides(a)**
+ Evaluates to an array of type ``npy_intp`` and length
+ ``array_numdims(a)``, giving the stridess of all of the dimensions
+ of ``a``, assuming ``a`` can be cast to a ``PyArrayObject*``. A
+ stride is the distance in bytes between an element and its
+ immediate neighbor along the same axis.
+
+ **array_stride(a,i)**
+ Evaluates to the ``i``-th stride of ``a``, assuming ``a`` can be
+ cast to a ``PyArrayObject*``.
+
**array_data(a)**
Evaluates to a pointer of type ``void*`` that points to the data
buffer of ``a``, assuming ``a`` can be cast to a ``PyArrayObject*``.
+ **array_descr(a)**
+ Returns a borrowed reference to the dtype property
+ (``PyArray_Descr*``) of ``a``, assuming ``a`` can be cast to a
+ ``PyArrayObject*``.
+
+ **array_flags(a)**
+ Returns an integer representing the flags of ``a``, assuming ``a``
+ can be cast to a ``PyArrayObject*``.
+
+ **array_enableflags(a,f)**
+ Sets the flag represented by ``f`` of ``a``, assuming ``a`` can be
+ cast to a ``PyArrayObject*``.
+
**array_is_contiguous(a)**
Evaluates as true if ``a`` is a contiguous array. Equivalent to
``(PyArray_ISCONTIGUOUS(a))``.
@@ -576,7 +660,7 @@ Routines
**pytype_string()**
- Return type: ``char*``
+ Return type: ``const char*``
Arguments:
@@ -587,7 +671,7 @@ Routines
**typecode_string()**
- Return type: ``char*``
+ Return type: ``const char*``
Arguments:
@@ -668,6 +752,23 @@ Routines
as a new object and return the pointer.
+ **make_fortran()**
+
+ Return type: ``PyArrayObject*``
+
+ Arguments
+
+ * ``PyArrayObject* ary``, a NumPy array.
+
+ * ``int* is_new_object``, returns a value of 0 if no conversion
+ performed, else 1.
+
+ Check to see if ``ary`` is Fortran contiguous. If so, return the
+ input pointer and 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.
+
+
**obj_to_array_contiguous_allow_conversion()**
Return type: ``PyArrayObject*``
@@ -688,6 +789,26 @@ Routines
flag will be set.
+ **obj_to_array_fortran_allow_conversion()**
+
+ Return type: ``PyArrayObject*``
+
+ Arguments:
+
+ * ``PyObject* input``, a general Python object.
+
+ * ``int typecode``, the desired NumPy typecode of the resulting
+ array.
+
+ * ``int* is_new_object``, returns a value of 0 if no conversion
+ performed, else 1.
+
+ Convert ``input`` to a Fortran contiguous ``PyArrayObject*`` of
+ the specified type. If the input object is not a Fortran
+ contiguous ``PyArrayObject*``, a new one will be created and the
+ new object flag will be set.
+
+
**require_contiguous()**
Return type: ``int``
@@ -772,9 +893,9 @@ Routines
* ``PyArrayObject* ary``, a NumPy array.
- 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.
+ 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.
Beyond the Provided Typemaps
@@ -848,7 +969,7 @@ There are other wrapping situations in which ``numpy.i`` may be
helpful when you encounter them.
* In some situations, it is possible that you could use the
- ``%numpy_templates`` macro to implement typemaps for your own
+ ``%numpy_typemaps`` macro to implement typemaps for your own
types. See the `Other Common Types: bool`_ or `Other Common
Types: complex`_ sections for examples. Another situation is if
your dimensions are of a type other than ``int`` (say ``long`` for
@@ -857,10 +978,10 @@ helpful when you encounter them.
%numpy_typemaps(double, NPY_DOUBLE, long)
* You can use the code in ``numpy.i`` to write your own typemaps.
- For example, if you had a four-dimensional array as a function
- argument, you could cut-and-paste the appropriate
- three-dimensional typemaps into your interface file. The
- modifications for the fourth dimension would be trivial.
+ For example, if you had a five-dimensional array as a function
+ argument, you could cut-and-paste the appropriate four-dimensional
+ typemaps into your interface file. The modifications for the
+ fourth dimension would be trivial.
* Sometimes, the best approach is to use the ``%extend`` directive
to define new methods for your classes (or overload existing ones)
@@ -903,27 +1024,32 @@ between NumPy arrays and C arrays:
``unsigned int``, ``long``, ``unsigned long``, ``long long``,
``unsigned long long``, ``float`` and ``double``.
- * That support 41 different argument signatures for each data type,
+ * That support 74 different argument signatures for each data type,
including:
- + One-dimensional, two-dimensional and three-dimensional arrays.
+ + One-dimensional, two-dimensional, three-dimensional and
+ four-dimensional arrays.
- + Input-only, in-place, argout and argoutview behavior.
+ + Input-only, in-place, argout, argoutview, and memory managed
+ argoutview behavior.
+ Hard-coded dimensions, data-buffer-then-dimensions
specification, and dimensions-then-data-buffer specification.
- + Both C-ordering ("last dimension fastest") or FORTRAN-ordering
- ("first dimension fastest") support for 2D and 3D arrays.
+ + Both C-ordering ("last dimension fastest") or Fortran-ordering
+ ("first dimension fastest") support for 2D, 3D and 4D arrays.
The ``numpy.i`` interface file also provides additional tools for
wrapper developers, including:
* A `SWIG`_ macro (``%numpy_typemaps``) with three arguments for
- implementing the 41 argument signatures for the user's choice of
+ implementing the 74 argument signatures for the user's choice of
(1) C data type, (2) NumPy data type (assuming they match), and
(3) dimension type.
- * Nine C macros and 13 C functions that can be used to write
- specialized typemaps, extensions, or inlined functions that handle
- cases not covered by the provided typemaps.
+ * Fourteen C macros and fifteen C functions that can be used to
+ write specialized typemaps, extensions, or inlined functions that
+ handle cases not covered by the provided typemaps. Note that the
+ macros and functions are coded specifically to work with the NumPy
+ C/API regardless of NumPy version number, both before and after
+ the deprecation of some aspects of the API after version 1.6.
diff --git a/doc/source/reference/swig.testing.rst b/doc/source/reference/swig.testing.rst
index 4aad6bff7..8b19e4b28 100644
--- a/doc/source/reference/swig.testing.rst
+++ b/doc/source/reference/swig.testing.rst
@@ -6,11 +6,11 @@ Introduction
Writing tests for the ``numpy.i`` `SWIG <http://www.swig.org>`_
interface file is a combinatorial headache. At present, 12 different
-data types are supported, each with 23 different argument signatures,
-for a total of 276 typemaps supported "out of the box". Each of these
+data types are supported, each with 74 different argument signatures,
+for a total of 888 typemaps supported "out of the box". Each of these
typemaps, in turn, might require several unit tests in order to verify
expected behavior for both proper and improper inputs. Currently,
-this results in 1,020 individual unit tests that are performed when
+this results in 1,427 individual unit tests that are performed when
``make test`` is run in the ``numpy/docs/swig`` subdirectory.
To facilitate this many similar unit tests, some high-level
@@ -56,9 +56,11 @@ each data type supported.
Two-dimensional arrays are tested in exactly the same manner. The
above description applies, but with ``Matrix`` substituted for
``Vector``. For three-dimensional tests, substitute ``Tensor`` for
-``Vector``. For the descriptions that follow, we will reference the
-``Vector`` tests, but the same information applies to ``Matrix`` and
-``Tensor`` tests.
+``Vector``. For four-dimensional tests, substitute ``SuperTensor``
+for ``Vector``.
+For the descriptions that follow, we will reference the
+``Vector`` tests, but the same information applies to ``Matrix``,
+``Tensor`` and ``SuperTensor`` tests.
The command ``make test`` will ensure that all of the test software is
built and then run all three test scripts.
diff --git a/doc/swig/Makefile b/doc/swig/Makefile
index 79eb33fcc..0478ac76f 100644
--- a/doc/swig/Makefile
+++ b/doc/swig/Makefile
@@ -1,5 +1,5 @@
# List all of the subdirectories here for recursive make
-SUBDIRS = test doc
+SUBDIRS = test
# Default target
.PHONY : default
diff --git a/doc/swig/README b/doc/swig/README
index 4a10e436b..df5dbfc47 100644
--- a/doc/swig/README
+++ b/doc/swig/README
@@ -9,8 +9,8 @@ distribution.
Documentation
-------------
-Documentation for how to use numpy.i, as well as for the testing system
-used here, can be found in the NumPy reference guide.
+Documentation for how to use numpy.i, as well as for the testing
+system used here, can be found in the NumPy reference guide.
Testing
-------
@@ -32,6 +32,11 @@ The files related to testing are are in the test subdirectory::
Tensor.i
testTensor.py
+ SuperTensor.h
+ SuperTensor.cxx
+ SuperTensor.i
+ testSuperTensor.py
+
The header files contain prototypes for functions that illustrate the
wrapping issues we wish to address. Right now, this consists of
functions with argument signatures of the following forms. Vector.h::
@@ -72,8 +77,21 @@ Tensor.h::
(type ARGOUT_ARRAY3[ANY][ANY][ANY])
+SuperTensor.h::
+
+ (type IN_ARRAY4[ANY][ANY][ANY][ANY])
+ (type* IN_ARRAY4, int DIM1, int DIM2, int DIM3, int DIM4)
+ (int DIM1, int DIM2, int DIM3, int DIM4, type* IN_ARRAY4)
+
+ (type INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
+ (type* INPLACE_ARRAY4, int DIM1, int DIM2, int DIM3, int DIM4)
+ (int DIM1, int DIM2, int DIM3, int DIM4, type* INPLACE_ARRAY4)
+
+ (type ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
+
These function signatures take a pointer to an array of type "type",
-whose length is specified by the integer(s) DIM1 (and DIM2, and DIM3).
+whose length is specified by the integer(s) DIM1 (and DIM2, and DIM3,
+and DIM4).
The objective for the IN_ARRAY signatures is for SWIG to generate
python wrappers that take a container that constitutes a valid
@@ -87,25 +105,27 @@ The objective for the INPLACE_ARRAY signatures is for SWIG to generate
python wrappers that accept a numpy array of any of the above-listed
types.
-The source files Vector.cxx, Matrix.cxx and Tensor.cxx contain the
-actual implementations of the functions described in Vector.h,
-Matrix.h and Tensor.h. The python scripts testVector.py,
-testMatrix.py and testTensor.py test the resulting python wrappers
-using the unittest module.
-
-The SWIG interface files Vector.i, Matrix.i and Tensor.i are used to
-generate the wrapper code. The SWIG_FILE_WITH_INIT macro allows
-numpy.i to be used with multiple python modules. If it is specified,
-then the %init block found in Vector.i, Matrix.i and Tensor.i are
-required. The other things done in Vector.i, Matrix.i and Tensor.i
-are the inclusion of the appropriate header file and numpy.i file, and
-the "%apply" directives to force the functions to use the typemaps.
+The source files Vector.cxx, Matrix.cxx Tensor.cxx and SuperTensor.cxx
+contain the actual implementations of the functions described in
+Vector.h, Matrix.h Tensor.h and SuperTensor.h. The python scripts
+testVector.py, testMatrix.py testTensor.py and testSuperTensor.py
+test the resulting python wrappers using the unittest module.
+
+The SWIG interface files Vector.i, Matrix.i Tensor.i and SuperTensor.i
+are used to generate the wrapper code. The SWIG_FILE_WITH_INIT macro
+allows numpy.i to be used with multiple python modules. If it is
+specified, then the %init block found in Vector.i, Matrix.i Tensor.i
+and SuperTensor.i are required. The other things done in Vector.i,
+Matrix.i Tensor.i and SuperTensor.i are the inclusion of the
+appropriate header file and numpy.i file, and the "%apply" directives
+to force the functions to use the typemaps.
The setup.py script is a standard python distutils script. It defines
-_Vector, _Matrix and _Tensor extension modules and Vector, Matrix and
-Tensor python modules. The Makefile automates everything, setting up
-the dependencies, calling swig to generate the wrappers, and calling
-setup.py to compile the wrapper code and generate the shared objects.
+_Vector, _Matrix _Tensor and _SuperTensor extension modules and Vector
+, Matrix, Tensor and SuperTensor python modules. The Makefile
+automates everything, setting up the dependencies, calling swig to
+generate the wrappers, and calling setup.py to compile the wrapper
+code and generate the shared objects.
Targets "all" (default), "test", "doc" and "clean" are supported. The
"doc" target creates HTML documentation (with make target "html"), and
PDF documentation (with make targets "tex" and "pdf").
diff --git a/doc/swig/numpy.i b/doc/swig/numpy.i
index 4de4a2036..f2714cc34 100644
--- a/doc/swig/numpy.i
+++ b/doc/swig/numpy.i
@@ -3,14 +3,26 @@
%{
#ifndef SWIG_FILE_WITH_INIT
-# define NO_IMPORT_ARRAY
+#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
@@ -23,24 +35,45 @@
{
/* Macros to extract array attributes.
*/
-%#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a))
-%#define array_type(a) (int)(PyArray_TYPE(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_data(a) (((PyArrayObject *)a)->data)
-%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
-%#define array_is_native(a) (PyArray_ISNOTSWAPPED(a))
-%#define array_is_fortran(a) (PyArray_ISFORTRAN(a))
+%#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
+%#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)
+%#endif
+%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a))
+%#define array_is_native(a) (PyArray_ISNOTSWAPPED((PyArrayObject*)a))
+%#define array_is_fortran(a) (PyArray_ISFORTRAN((PyArrayObject*)a))
}
/**********************************************************************/
-%fragment("NumPy_Utilities", "header")
+%fragment("NumPy_Utilities",
+ "header")
{
/* Given a PyObject, return a string describing its type.
*/
- const char* pytype_string(PyObject* py_obj) {
+ 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" ;
@@ -50,9 +83,9 @@
if (PyDict_Check( py_obj)) return "dict" ;
if (PyList_Check( py_obj)) return "list" ;
if (PyTuple_Check( py_obj)) return "tuple" ;
- if (PyModule_Check( py_obj)) return "module" ;
%#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
@@ -61,31 +94,60 @@
/* 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"};
+ 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. Allow character and byte
- * to match. Also allow int and long to match. This is deprecated.
- * You should use PyArray_EquivTypenums() instead.
+ /* Make sure input has correct numpy type. This now just calls
+ PyArray_EquivTypenums().
*/
- int type_match(int actual_type, int desired_type) {
+ 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_Object_to_Array",
+ "header",
fragment="NumPy_Backward_Compatibility",
fragment="NumPy_Macros",
fragment="NumPy_Utilities")
@@ -94,7 +156,8 @@
* legal. If not, set the python error string appropriately and
* return NULL.
*/
- PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode)
+ PyArrayObject* obj_to_array_no_conversion(PyObject* input,
+ int typecode)
{
PyArrayObject* ary = NULL;
if (is_array(input) && (typecode == NPY_NOTYPE ||
@@ -113,11 +176,12 @@
}
else
{
- const char * desired_type = typecode_string(typecode);
- const char * actual_type = pytype_string(input);
+ 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);
+ desired_type,
+ actual_type);
ary = NULL;
}
return ary;
@@ -128,11 +192,12 @@
* 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* obj_to_array_allow_conversion(PyObject* input,
+ int typecode,
+ int* is_new_object)
{
PyArrayObject* ary = NULL;
- PyObject* py_obj;
+ PyObject* py_obj;
if (is_array(input) && (typecode == NPY_NOTYPE ||
PyArray_EquivTypenums(array_type(input),typecode)))
{
@@ -141,7 +206,7 @@
}
else
{
- py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_DEFAULT);
+ 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;
@@ -154,8 +219,10 @@
* 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* make_contiguous(PyArrayObject* ary,
+ int* is_new_object,
+ int min_dims,
+ int max_dims)
{
PyArrayObject* result;
if (array_is_contiguous(ary))
@@ -166,9 +233,9 @@
else
{
result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
- array_type(ary),
- min_dims,
- max_dims);
+ array_type(ary),
+ min_dims,
+ max_dims);
*is_new_object = 1;
}
return result;
@@ -180,8 +247,8 @@
* PyArrayObject using the original data, flag it as a new object
* and return the pointer.
*/
- PyArrayObject* make_fortran(PyArrayObject* ary, int* is_new_object,
- int min_dims, int max_dims)
+ PyArrayObject* make_fortran(PyArrayObject* ary,
+ int* is_new_object)
{
PyArrayObject* result;
if (array_is_fortran(ary))
@@ -191,8 +258,10 @@
}
else
{
- Py_INCREF(ary->descr);
- result = (PyArrayObject*) PyArray_FromArray(ary, ary->descr, NPY_FORTRAN);
+ Py_INCREF(array_descr(ary));
+ result = (PyArrayObject*) PyArray_FromArray(ary,
+ array_descr(ary),
+ NPY_FORTRANORDER);
*is_new_object = 1;
}
return result;
@@ -204,13 +273,14 @@
* will be set.
*/
PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
- int typecode,
- int* is_new_object)
+ 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,
+ PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
+ typecode,
&is_new1);
if (ary1)
{
@@ -231,17 +301,18 @@
* will be set.
*/
PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
- int typecode,
- int* is_new_object)
+ 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,
+ PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
+ typecode,
&is_new1);
if (ary1)
{
- ary2 = make_fortran(ary1, &is_new2, 0, 0);
+ ary2 = make_fortran(ary1, &is_new2);
if (is_new1 && is_new2)
{
Py_DECREF(ary1);
@@ -251,13 +322,12 @@
*is_new_object = is_new1 || is_new2;
return ary1;
}
-
} /* end fragment */
-
/**********************************************************************/
-%fragment("NumPy_Array_Requirements", "header",
+%fragment("NumPy_Array_Requirements",
+ "header",
fragment="NumPy_Backward_Compatibility",
fragment="NumPy_Macros")
{
@@ -298,14 +368,16 @@
* 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 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));
+ exact_dimensions,
+ array_numdims(ary));
success = 0;
}
return success;
@@ -316,7 +388,9 @@
* 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 require_dimensions_n(PyArrayObject* ary,
+ int* exact_dimensions,
+ int n)
{
int success = 0;
int i;
@@ -340,7 +414,8 @@
strcat(dims_str,s);
PyErr_Format(PyExc_TypeError,
"Array must have %s dimensions. Given array has %d dimensions",
- dims_str, array_numdims(ary));
+ dims_str,
+ array_numdims(ary));
}
return success;
}
@@ -349,7 +424,9 @@
* 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 require_size(PyArrayObject* ary,
+ npy_intp* size,
+ int n)
{
int i;
int success = 1;
@@ -389,104 +466,150 @@
actual_dims[len-1] = ']';
PyErr_Format(PyExc_TypeError,
"Array must have shape of %s. Given array has shape of %s",
- desired_dims, actual_dims);
+ 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.
+ /* 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 */
- ary->flags = NPY_FARRAY;
+ /* Set the Fortran ordered flag */
+ array_enableflags(ary,NPY_ARRAY_FARRAY);
/* Recompute the strides */
- ary->strides[0] = ary->strides[nd-1];
+ strides[0] = strides[nd-1];
for (i=1; i < nd; ++i)
- ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1);
+ 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_Fragments",
+ "header",
fragment="NumPy_Backward_Compatibility",
fragment="NumPy_Macros",
fragment="NumPy_Utilities",
fragment="NumPy_Object_to_Array",
- fragment="NumPy_Array_Requirements") { }
+ fragment="NumPy_Array_Requirements")
+{
+}
/* End John Hunter translation (with modifications by Bill Spotz)
*/
/* %numpy_typemaps() macro
*
- * This macro defines a family of 41 typemaps that allow C arguments
+ * This macro defines a family of 74 typemaps that allow C arguments
* of the form
*
- * (DATA_TYPE IN_ARRAY1[ANY])
- * (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
- * (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ * 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)
*
- * (DATA_TYPE IN_ARRAY2[ANY][ANY])
- * (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
- * (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ * 21. (DATA_TYPE INPLACE_ARRAY1[ANY])
+ * 22. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ * 23. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
*
- * (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
- * (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
- * (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+ * 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)
*
- * (DATA_TYPE INPLACE_ARRAY1[ANY])
- * (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
- * (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ * 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)
*
- * (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
- * (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
- * (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ * 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)
*
- * (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
- * (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
- * (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+ * 41. (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ * 42. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ * 43. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
*
- * (DATA_TYPE ARGOUT_ARRAY1[ANY])
- * (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
- * (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ * 44. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
*
- * (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ * 45. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
*
- * (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ * 46. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
*
- * (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
- * (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ * 47. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ * 48. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
*
- * (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
- * (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ * 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)
*
- * (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
- * (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ * 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)
*
* 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
+ * 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
@@ -546,7 +669,8 @@
(PyArrayObject* array=NULL, int is_new_object=0)
{
npy_intp size[1] = { $1_dim0 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ 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;
@@ -573,7 +697,8 @@
(PyArrayObject* array=NULL, int is_new_object=0)
{
npy_intp size[1] = { -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ 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;
@@ -601,7 +726,8 @@
(PyArrayObject* array=NULL, int is_new_object=0)
{
npy_intp size[1] = {-1};
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ 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;
@@ -629,7 +755,8 @@
(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,
+ 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;
@@ -685,7 +812,8 @@
(PyArrayObject* array=NULL, int is_new_object=0)
{
npy_intp size[2] = { -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ 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;
@@ -714,7 +842,8 @@
(PyArrayObject* array=NULL, int is_new_object=0)
{
npy_intp size[2] = { -1, -1 };
- array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+ 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;
@@ -743,7 +872,8 @@
(PyArrayObject* array=NULL, int is_new_object=0)
{
npy_intp size[2] = { -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+ array = obj_to_array_contiguous_allow_conversion($input,
+ DATA_TYPECODE,
&is_new_object);
if (!array || !require_dimensions(array, 2) ||
!require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
@@ -772,7 +902,8 @@
(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,
+ 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;
@@ -816,6 +947,88 @@
{ 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)
*/
@@ -893,7 +1106,8 @@
(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,
+ array = obj_to_array_contiguous_allow_conversion($input,
+ DATA_TYPECODE,
&is_new_object);
if (!array || !require_dimensions(array, 3) ||
!require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
@@ -909,6 +1123,245 @@
{ 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_contiguous_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 */
/***************************/
@@ -1132,6 +1585,72 @@
$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)
*/
@@ -1204,6 +1723,195 @@
$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 */
/*************************/
@@ -1213,7 +1921,7 @@
%typemap(in,numinputs=0,
fragment="NumPy_Backward_Compatibility,NumPy_Macros")
(DATA_TYPE ARGOUT_ARRAY1[ANY])
- (PyObject * array = NULL)
+ (PyObject* array = NULL)
{
npy_intp dims[1] = { $1_dim0 };
array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
@@ -1223,7 +1931,7 @@
%typemap(argout)
(DATA_TYPE ARGOUT_ARRAY1[ANY])
{
- $result = SWIG_Python_AppendOutput($result,array$argnum);
+ $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
}
/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
@@ -1231,7 +1939,7 @@
%typemap(in,numinputs=1,
fragment="NumPy_Fragments")
(DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
- (PyObject * array = NULL)
+ (PyObject* array = NULL)
{
npy_intp dims[1];
if (!PyInt_Check($input))
@@ -1251,7 +1959,7 @@
%typemap(argout)
(DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
{
- $result = SWIG_Python_AppendOutput($result,array$argnum);
+ $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
}
/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
@@ -1259,7 +1967,7 @@
%typemap(in,numinputs=1,
fragment="NumPy_Fragments")
(DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
- (PyObject * array = NULL)
+ (PyObject* array = NULL)
{
npy_intp dims[1];
if (!PyInt_Check($input))
@@ -1279,7 +1987,7 @@
%typemap(argout)
(DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
{
- $result = SWIG_Python_AppendOutput($result,array$argnum);
+ $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
}
/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
@@ -1287,7 +1995,7 @@
%typemap(in,numinputs=0,
fragment="NumPy_Backward_Compatibility,NumPy_Macros")
(DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
- (PyObject * array = NULL)
+ (PyObject* array = NULL)
{
npy_intp dims[2] = { $1_dim0, $1_dim1 };
array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
@@ -1297,7 +2005,7 @@
%typemap(argout)
(DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
{
- $result = SWIG_Python_AppendOutput($result,array$argnum);
+ $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
}
/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
@@ -1305,7 +2013,7 @@
%typemap(in,numinputs=0,
fragment="NumPy_Backward_Compatibility,NumPy_Macros")
(DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
- (PyObject * array = NULL)
+ (PyObject* array = NULL)
{
npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
@@ -1315,7 +2023,25 @@
%typemap(argout)
(DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
{
- $result = SWIG_Python_AppendOutput($result,array$argnum);
+ $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);
}
/*****************************/
@@ -1326,7 +2052,7 @@
*/
%typemap(in,numinputs=0)
(DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 )
- (DATA_TYPE* data_temp , DIM_TYPE dim_temp)
+ (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp)
{
$1 = &data_temp;
$2 = &dim_temp;
@@ -1336,16 +2062,18 @@
(DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
{
npy_intp dims[1] = { *$2 };
- PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+ PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+ PyArrayObject* array = (PyArrayObject*) obj;
+
if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,array);
+ $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 )
+ (DIM_TYPE dim_temp, DATA_TYPE* data_temp = NULL )
{
$1 = &dim_temp;
$2 = &data_temp;
@@ -1355,16 +2083,18 @@
(DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
{
npy_intp dims[1] = { *$1 };
- PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+ PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+ PyArrayObject* array = (PyArrayObject*) obj;
+
if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,array);
+ $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 , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
+ (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
{
$1 = &data_temp;
$2 = &dim1_temp;
@@ -1375,16 +2105,18 @@
(DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
{
npy_intp dims[2] = { *$2, *$3 };
- PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+ PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+ PyArrayObject* array = (PyArrayObject*) obj;
+
if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,array);
+ $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 )
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL )
{
$1 = &dim1_temp;
$2 = &dim2_temp;
@@ -1395,16 +2127,18 @@
(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
{
npy_intp dims[2] = { *$1, *$2 };
- PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+ PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+ PyArrayObject* array = (PyArrayObject*) obj;
+
if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,array);
+ $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 , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
+ (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
{
$1 = &data_temp;
$2 = &dim1_temp;
@@ -1415,8 +2149,9 @@
(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;
+ 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);
}
@@ -1425,7 +2160,7 @@
*/
%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 )
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL )
{
$1 = &dim1_temp;
$2 = &dim2_temp;
@@ -1436,8 +2171,9 @@
(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;
+ 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);
}
@@ -1446,8 +2182,8 @@
DIM_TYPE* DIM3)
*/
%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+ (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;
@@ -1459,9 +2195,11 @@
(DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
{
npy_intp dims[3] = { *$2, *$3, *$4 };
- PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+ PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+ PyArrayObject* array = (PyArrayObject*) obj;
+
if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,array);
+ $result = SWIG_Python_AppendOutput($result,obj);
}
/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
@@ -1469,7 +2207,7 @@
*/
%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)
+ (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL)
{
$1 = &dim1_temp;
$2 = &dim2_temp;
@@ -1481,17 +2219,19 @@
(DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
{
npy_intp dims[3] = { *$1, *$2, *$3 };
- PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+ PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
+ PyArrayObject* array = (PyArrayObject*) obj;
+
if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,array);
+ $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, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+ (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;
@@ -1503,8 +2243,9 @@
(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;
+ 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);
}
@@ -1513,8 +2254,8 @@
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)
+ (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;
@@ -1526,12 +2267,777 @@
(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*)(*$3));
- PyArrayObject * array = (PyArrayObject*) obj;
+ 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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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")
+ (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);
+}
+
%enddef /* %numpy_typemaps() macro */
/* *************************************************************** */
diff --git a/doc/swig/pyfragments.swg b/doc/swig/pyfragments.swg
index 8f077ee62..b5decf12c 100644
--- a/doc/swig/pyfragments.swg
+++ b/doc/swig/pyfragments.swg
@@ -22,7 +22,7 @@
SWIGINTERN int
SWIG_AsVal_dec(long)(PyObject * obj, long * val)
{
- static PyArray_Descr * longDescr = PyArray_DescrNewFromType(NPY_LONG);
+ PyArray_Descr * longDescr = PyArray_DescrNewFromType(NPY_LONG);
if (PyInt_Check(obj)) {
if (val) *val = PyInt_AsLong(obj);
return SWIG_OK;
@@ -74,7 +74,7 @@
SWIGINTERN int
SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
{
- static PyArray_Descr * ulongDescr = PyArray_DescrNewFromType(NPY_ULONG);
+ PyArray_Descr * ulongDescr = PyArray_DescrNewFromType(NPY_ULONG);
if (PyInt_Check(obj)) {
long v = PyInt_AsLong(obj);
if (v >= 0) {
diff --git a/doc/swig/test/Array.i b/doc/swig/test/Array.i
index d56dd2d1c..6a8605eb6 100644
--- a/doc/swig/test/Array.i
+++ b/doc/swig/test/Array.i
@@ -50,11 +50,6 @@
{(int nrows, int ncols, long* data )};
%apply (int* DIM1 , int* DIM2 , long** ARGOUTVIEW_ARRAY2)
{(int* nrows, int* ncols, long** data )};
-// Note: the %apply for INPLACE_ARRAY2 above gets successfully applied
-// to the constructor Array2(int nrows, int ncols, long* data), but
-// does not get applied to the method Array2::resize(int nrows, int
-// ncols, long* data). I have no idea why. For this reason the test
-// for Apply2.resize(numpy.ndarray) in testArray.py is commented out.
// Array1 support
%include "Array1.h"
diff --git a/doc/swig/test/Array2.h b/doc/swig/test/Array2.h
index a6e5bfc30..7f8d4ca65 100644
--- a/doc/swig/test/Array2.h
+++ b/doc/swig/test/Array2.h
@@ -32,7 +32,7 @@ public:
int ncols() const;
// Resize array
- void resize(int ncols, int nrows, long* data=0);
+ void resize(int nrows, int ncols, long* data=0);
// Set item accessor
Array1 & operator[](int i);
diff --git a/doc/swig/test/SuperTensor.cxx b/doc/swig/test/SuperTensor.cxx
new file mode 100644
index 000000000..82e8a4bd5
--- /dev/null
+++ b/doc/swig/test/SuperTensor.cxx
@@ -0,0 +1,144 @@
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+#include "SuperTensor.h"
+
+// The following macro defines a family of functions that work with 3D
+// arrays with the forms
+//
+// TYPE SNAMENorm( TYPE supertensor[2][2][2][2]);
+// TYPE SNAMEMax( TYPE * supertensor, int cubes, int slices, int rows, int cols);
+// TYPE SNAMEMin( int cubes, int slices, int rows, int cols, TYPE * supertensor);
+// void SNAMEScale( TYPE supertensor[3][3][3][3]);
+// void SNAMEFloor( TYPE * array, int cubes, int slices, int rows, int cols, TYPE floor);
+// void SNAMECeil( int slices, int cubes, int slices, int rows, int cols, TYPE * array, TYPE ceil);
+// void SNAMELUSplit(TYPE in[2][2][2][2], TYPE lower[2][2][2][2], TYPE upper[2][2][2][2]);
+//
+// for any specified type TYPE (for example: short, unsigned int, long
+// long, etc.) with given short name SNAME (for example: short, uint,
+// longLong, etc.). The macro is then expanded for the given
+// TYPE/SNAME pairs. The resulting functions are for testing numpy
+// interfaces, respectively, for:
+//
+// * 4D input arrays, hard-coded length
+// * 4D input arrays
+// * 4D input arrays, data last
+// * 4D in-place arrays, hard-coded lengths
+// * 4D in-place arrays
+// * 4D in-place arrays, data last
+// * 4D argout arrays, hard-coded length
+//
+#define TEST_FUNCS(TYPE, SNAME) \
+\
+TYPE SNAME ## Norm(TYPE supertensor[2][2][2][2]) { \
+ double result = 0; \
+ for (int l=0; l<2; ++l) \
+ for (int k=0; k<2; ++k) \
+ for (int j=0; j<2; ++j) \
+ for (int i=0; i<2; ++i) \
+ result += supertensor[l][k][j][i] * supertensor[l][k][j][i]; \
+ return (TYPE)sqrt(result/16); \
+} \
+\
+TYPE SNAME ## Max(TYPE * supertensor, int cubes, int slices, int rows, int cols) { \
+ int i, j, k, l, index; \
+ TYPE result = supertensor[0]; \
+ for (l=0; l<cubes; ++l) { \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = l*slices*rows*cols + k*rows*cols + j*cols + i; \
+ if (supertensor[index] > result) result = supertensor[index]; \
+ } \
+ } \
+ } \
+ } \
+ return result; \
+} \
+\
+TYPE SNAME ## Min(int cubes, int slices, int rows, int cols, TYPE * supertensor) { \
+ int i, j, k, l, index; \
+ TYPE result = supertensor[0]; \
+ for (l=0; l<cubes; ++l) { \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = l*slices*rows*cols + k*rows*cols + j*cols + i; \
+ if (supertensor[index] < result) result = supertensor[index]; \
+ } \
+ } \
+ } \
+ } \
+ return result; \
+} \
+\
+void SNAME ## Scale(TYPE array[3][3][3][3], TYPE val) { \
+ for (int l=0; l<3; ++l) \
+ for (int k=0; k<3; ++k) \
+ for (int j=0; j<3; ++j) \
+ for (int i=0; i<3; ++i) \
+ array[l][k][j][i] *= val; \
+} \
+\
+void SNAME ## Floor(TYPE * array, int cubes, int slices, int rows, int cols, TYPE floor) { \
+ int i, j, k, l, index; \
+ for (l=0; l<cubes; ++l) { \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = l*slices*rows*cols + k*rows*cols + j*cols + i; \
+ if (array[index] < floor) array[index] = floor; \
+ } \
+ } \
+ } \
+ } \
+} \
+\
+void SNAME ## Ceil(int cubes, int slices, int rows, int cols, TYPE * array, TYPE ceil) { \
+ int i, j, k, l, index; \
+ for (l=0; l<cubes; ++l) { \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = l*slices*rows*cols + k*rows*cols + j*cols + i; \
+ if (array[index] > ceil) array[index] = ceil; \
+ } \
+ } \
+ } \
+ } \
+} \
+\
+void SNAME ## LUSplit(TYPE supertensor[2][2][2][2], TYPE lower[2][2][2][2], \
+ TYPE upper[2][2][2][2]) { \
+ int sum; \
+ for (int l=0; l<2; ++l) { \
+ for (int k=0; k<2; ++k) { \
+ for (int j=0; j<2; ++j) { \
+ for (int i=0; i<2; ++i) { \
+ sum = i + j + k + l; \
+ if (sum < 2) { \
+ lower[l][k][j][i] = supertensor[l][k][j][i]; \
+ upper[l][k][j][i] = 0; \
+ } else { \
+ upper[l][k][j][i] = supertensor[l][k][j][i]; \
+ lower[l][k][j][i] = 0; \
+ } \
+ } \
+ } \
+ } \
+ } \
+}
+
+TEST_FUNCS(signed char , schar )
+TEST_FUNCS(unsigned char , uchar )
+TEST_FUNCS(short , short )
+TEST_FUNCS(unsigned short , ushort )
+TEST_FUNCS(int , int )
+TEST_FUNCS(unsigned int , uint )
+TEST_FUNCS(long , long )
+TEST_FUNCS(unsigned long , ulong )
+TEST_FUNCS(long long , longLong )
+TEST_FUNCS(unsigned long long, ulongLong)
+TEST_FUNCS(float , float )
+TEST_FUNCS(double , double )
+
diff --git a/doc/swig/test/SuperTensor.h b/doc/swig/test/SuperTensor.h
new file mode 100644
index 000000000..29cc3bbbb
--- /dev/null
+++ b/doc/swig/test/SuperTensor.h
@@ -0,0 +1,53 @@
+#ifndef SUPERTENSOR_H
+#define SUPERTENSOR_H
+
+// The following macro defines the prototypes for a family of
+// functions that work with 4D arrays with the forms
+//
+// TYPE SNAMENorm( TYPE supertensor[2][2][2][2]);
+// TYPE SNAMEMax( TYPE * supertensor, int cubes, int slices, int rows, int cols);
+// TYPE SNAMEMin( int cubes, int slices, int rows, int cols, TYPE * supertensor);
+// void SNAMEScale( TYPE array[3][3][3][3]);
+// void SNAMEFloor( TYPE * array, int cubes, int slices, int rows, int cols, TYPE floor);
+// void SNAMECeil( int cubes, int slices, int rows, int cols, TYPE * array, TYPE ceil );
+// void SNAMELUSplit(TYPE in[3][3][3][3], TYPE lower[3][3][3][3], TYPE upper[3][3][3][3]);
+//
+// for any specified type TYPE (for example: short, unsigned int, long
+// long, etc.) with given short name SNAME (for example: short, uint,
+// longLong, etc.). The macro is then expanded for the given
+// TYPE/SNAME pairs. The resulting functions are for testing numpy
+// interfaces, respectively, for:
+//
+// * 4D input arrays, hard-coded lengths
+// * 4D input arrays
+// * 4D input arrays, data last
+// * 4D in-place arrays, hard-coded lengths
+// * 4D in-place arrays
+// * 4D in-place arrays, data last
+// * 4D argout arrays, hard-coded length
+//
+#define TEST_FUNC_PROTOS(TYPE, SNAME) \
+\
+TYPE SNAME ## Norm( TYPE supertensor[2][2][2][2]); \
+TYPE SNAME ## Max( TYPE * supertensor, int cubes, int slices, int rows, int cols); \
+TYPE SNAME ## Min( int cubes, int slices, int rows, int cols, TYPE * supertensor); \
+void SNAME ## Scale( TYPE array[3][3][3][3], TYPE val); \
+void SNAME ## Floor( TYPE * array, int cubes, int slices, int rows, int cols, TYPE floor); \
+void SNAME ## Ceil( int cubes, int slices, int rows, int cols, TYPE * array, TYPE ceil ); \
+void SNAME ## LUSplit(TYPE supertensor[2][2][2][2], TYPE lower[2][2][2][2], TYPE upper[2][2][2][2]);
+
+TEST_FUNC_PROTOS(signed char , schar )
+TEST_FUNC_PROTOS(unsigned char , uchar )
+TEST_FUNC_PROTOS(short , short )
+TEST_FUNC_PROTOS(unsigned short , ushort )
+TEST_FUNC_PROTOS(int , int )
+TEST_FUNC_PROTOS(unsigned int , uint )
+TEST_FUNC_PROTOS(long , long )
+TEST_FUNC_PROTOS(unsigned long , ulong )
+TEST_FUNC_PROTOS(long long , longLong )
+TEST_FUNC_PROTOS(unsigned long long, ulongLong)
+TEST_FUNC_PROTOS(float , float )
+TEST_FUNC_PROTOS(double , double )
+
+#endif
+
diff --git a/doc/swig/test/SuperTensor.i b/doc/swig/test/SuperTensor.i
new file mode 100644
index 000000000..7521b8ec4
--- /dev/null
+++ b/doc/swig/test/SuperTensor.i
@@ -0,0 +1,50 @@
+// -*- c++ -*-
+%module SuperTensor
+
+%{
+#define SWIG_FILE_WITH_INIT
+#include "SuperTensor.h"
+%}
+
+// Get the NumPy typemaps
+%include "../numpy.i"
+
+%init %{
+ import_array();
+%}
+
+%define %apply_numpy_typemaps(TYPE)
+
+%apply (TYPE IN_ARRAY4[ANY][ANY][ANY][ANY]) {(TYPE supertensor[ANY][ANY][ANY][ANY])};
+%apply (TYPE* IN_ARRAY4, int DIM1, int DIM2, int DIM3, int DIM4)
+ {(TYPE* supertensor, int cubes, int slices, int rows, int cols)};
+%apply (int DIM1, int DIM2, int DIM3, int DIM4, TYPE* IN_ARRAY4)
+ {(int cubes, int slices, int rows, int cols, TYPE* supertensor)};
+
+%apply (TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY]) {(TYPE array[3][3][3][3])};
+%apply (TYPE* INPLACE_ARRAY4, int DIM1, int DIM2, int DIM3, int DIM4)
+ {(TYPE* array, int cubes, int slices, int rows, int cols)};
+%apply (int DIM1, int DIM2, int DIM3, int DIM4, TYPE* INPLACE_ARRAY4)
+ {(int cubes, int slices, int rows, int cols, TYPE* array)};
+
+%apply (TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) {(TYPE lower[2][2][2][2])};
+%apply (TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY]) {(TYPE upper[2][2][2][2])};
+
+%enddef /* %apply_numpy_typemaps() macro */
+
+%apply_numpy_typemaps(signed char )
+%apply_numpy_typemaps(unsigned char )
+%apply_numpy_typemaps(short )
+%apply_numpy_typemaps(unsigned short )
+%apply_numpy_typemaps(int )
+%apply_numpy_typemaps(unsigned int )
+%apply_numpy_typemaps(long )
+%apply_numpy_typemaps(unsigned long )
+%apply_numpy_typemaps(long long )
+%apply_numpy_typemaps(unsigned long long)
+%apply_numpy_typemaps(float )
+%apply_numpy_typemaps(double )
+
+// Include the header file to be wrapped
+%include "SuperTensor.h"
+
diff --git a/doc/swig/test/Tensor.cxx b/doc/swig/test/Tensor.cxx
index dce595291..4ccefa144 100644
--- a/doc/swig/test/Tensor.cxx
+++ b/doc/swig/test/Tensor.cxx
@@ -7,11 +7,11 @@
// arrays with the forms
//
// TYPE SNAMENorm( TYPE tensor[2][2][2]);
-// TYPE SNAMEMax( TYPE * tensor, int rows, int cols, int num);
-// TYPE SNAMEMin( int rows, int cols, int num, TYPE * tensor);
+// TYPE SNAMEMax( TYPE * tensor, int slices, int rows, int cols);
+// TYPE SNAMEMin( int slices, int rows, int cols TYPE * tensor);
// void SNAMEScale( TYPE tensor[3][3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, int num, TYPE floor);
-// void SNAMECeil( int rows, int cols, int num, TYPE * array, TYPE ceil);
+// void SNAMEFloor( TYPE * array, int slices, int rows, int cols, TYPE floor);
+// void SNAMECeil( int slices, int rows, int cols, TYPE * array, TYPE ceil);
// void SNAMELUSplit(TYPE in[2][2][2], TYPE lower[2][2][2], TYPE upper[2][2][2]);
//
// for any specified type TYPE (for example: short, unsigned int, long
@@ -35,32 +35,32 @@ TYPE SNAME ## Norm(TYPE tensor[2][2][2]) { \
for (int k=0; k<2; ++k) \
for (int j=0; j<2; ++j) \
for (int i=0; i<2; ++i) \
- result += tensor[i][j][k] * tensor[i][j][k]; \
+ result += tensor[k][j][i] * tensor[k][j][i]; \
return (TYPE)sqrt(result/8); \
} \
\
-TYPE SNAME ## Max(TYPE * tensor, int rows, int cols, int num) { \
+TYPE SNAME ## Max(TYPE * tensor, int slices, int rows, int cols) { \
int i, j, k, index; \
TYPE result = tensor[0]; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = k*rows*cols + j*rows + i; \
- if (tensor[index] > result) result = tensor[index]; \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = k*rows*cols + j*cols + i; \
+ if (tensor[index] > result) result = tensor[index]; \
} \
} \
} \
return result; \
} \
\
-TYPE SNAME ## Min(int rows, int cols, int num, TYPE * tensor) { \
+TYPE SNAME ## Min(int slices, int rows, int cols, TYPE * tensor) { \
int i, j, k, index; \
TYPE result = tensor[0]; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = k*rows*cols + j*rows + i; \
- if (tensor[index] < result) result = tensor[index]; \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = k*rows*cols + j*cols + i; \
+ if (tensor[index] < result) result = tensor[index]; \
} \
} \
} \
@@ -68,31 +68,31 @@ TYPE SNAME ## Min(int rows, int cols, int num, TYPE * tensor) { \
} \
\
void SNAME ## Scale(TYPE array[3][3][3], TYPE val) { \
- for (int i=0; i<3; ++i) \
+ for (int k=0; k<3; ++k) \
for (int j=0; j<3; ++j) \
- for (int k=0; k<3; ++k) \
- array[i][j][k] *= val; \
+ for (int i=0; i<3; ++i) \
+ array[k][j][i] *= val; \
} \
\
-void SNAME ## Floor(TYPE * array, int rows, int cols, int num, TYPE floor) { \
+void SNAME ## Floor(TYPE * array, int slices, int rows, int cols, TYPE floor) { \
int i, j, k, index; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = k*cols*rows + j*rows + i; \
- if (array[index] < floor) array[index] = floor; \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = k*rows*cols + j*cols + i; \
+ if (array[index] < floor) array[index] = floor; \
} \
} \
} \
} \
\
-void SNAME ## Ceil(int rows, int cols, int num, TYPE * array, TYPE ceil) { \
+void SNAME ## Ceil(int slices, int rows, int cols, TYPE * array, TYPE ceil) { \
int i, j, k, index; \
- for (k=0; k<num; ++k) { \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (array[index] > ceil) array[index] = ceil; \
+ for (k=0; k<slices; ++k) { \
+ for (j=0; j<rows; ++j) { \
+ for (i=0; i<cols; ++i) { \
+ index = k*rows*cols + j*cols + i; \
+ if (array[index] > ceil) array[index] = ceil; \
} \
} \
} \
@@ -104,14 +104,14 @@ void SNAME ## LUSplit(TYPE tensor[2][2][2], TYPE lower[2][2][2], \
for (int k=0; k<2; ++k) { \
for (int j=0; j<2; ++j) { \
for (int i=0; i<2; ++i) { \
- sum = i + j + k; \
- if (sum < 2) { \
- lower[i][j][k] = tensor[i][j][k]; \
- upper[i][j][k] = 0; \
- } else { \
- upper[i][j][k] = tensor[i][j][k]; \
- lower[i][j][k] = 0; \
- } \
+ sum = i + j + k; \
+ if (sum < 2) { \
+ lower[k][j][i] = tensor[k][j][i]; \
+ upper[k][j][i] = 0; \
+ } else { \
+ upper[k][j][i] = tensor[k][j][i]; \
+ lower[k][j][i] = 0; \
+ } \
} \
} \
} \
diff --git a/doc/swig/test/Tensor.h b/doc/swig/test/Tensor.h
index d60eb2d2e..1f483b328 100644
--- a/doc/swig/test/Tensor.h
+++ b/doc/swig/test/Tensor.h
@@ -5,11 +5,11 @@
// functions that work with 3D arrays with the forms
//
// TYPE SNAMENorm( TYPE tensor[2][2][2]);
-// TYPE SNAMEMax( TYPE * tensor, int rows, int cols, int num);
-// TYPE SNAMEMin( int rows, int cols, int num, TYPE * tensor);
+// TYPE SNAMEMax( TYPE * tensor, int slices, int rows, int cols);
+// TYPE SNAMEMin( int slices, int rows, int cols, TYPE * tensor);
// void SNAMEScale( TYPE array[3][3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, int num, TYPE floor);
-// void SNAMECeil( int rows, int cols, int num, TYPE * array, TYPE ceil );
+// void SNAMEFloor( TYPE * array, int slices, int rows, int cols, TYPE floor);
+// void SNAMECeil( int slices, int rows, int cols, TYPE * array, TYPE ceil );
// void SNAMELUSplit(TYPE in[3][3][3], TYPE lower[3][3][3], TYPE upper[3][3][3]);
//
// for any specified type TYPE (for example: short, unsigned int, long
@@ -29,11 +29,11 @@
#define TEST_FUNC_PROTOS(TYPE, SNAME) \
\
TYPE SNAME ## Norm( TYPE tensor[2][2][2]); \
-TYPE SNAME ## Max( TYPE * tensor, int rows, int cols, int num); \
-TYPE SNAME ## Min( int rows, int cols, int num, TYPE * tensor); \
+TYPE SNAME ## Max( TYPE * tensor, int slices, int rows, int cols); \
+TYPE SNAME ## Min( int slices, int rows, int cols, TYPE * tensor); \
void SNAME ## Scale( TYPE array[3][3][3], TYPE val); \
-void SNAME ## Floor( TYPE * array, int rows, int cols, int num, TYPE floor); \
-void SNAME ## Ceil( int rows, int cols, int num, TYPE * array, TYPE ceil ); \
+void SNAME ## Floor( TYPE * array, int slices, int rows, int cols, TYPE floor); \
+void SNAME ## Ceil( int slices, int rows, int cols, TYPE * array, TYPE ceil ); \
void SNAME ## LUSplit(TYPE tensor[2][2][2], TYPE lower[2][2][2], TYPE upper[2][2][2]);
TEST_FUNC_PROTOS(signed char , schar )
diff --git a/doc/swig/test/Tensor.i b/doc/swig/test/Tensor.i
index a1198dc9e..5bf9da7e2 100644
--- a/doc/swig/test/Tensor.i
+++ b/doc/swig/test/Tensor.i
@@ -17,15 +17,15 @@
%apply (TYPE IN_ARRAY3[ANY][ANY][ANY]) {(TYPE tensor[ANY][ANY][ANY])};
%apply (TYPE* IN_ARRAY3, int DIM1, int DIM2, int DIM3)
- {(TYPE* tensor, int rows, int cols, int num)};
+ {(TYPE* tensor, int slices, int rows, int cols)};
%apply (int DIM1, int DIM2, int DIM3, TYPE* IN_ARRAY3)
- {(int rows, int cols, int num, TYPE* tensor)};
+ {(int slices, int rows, int cols, TYPE* tensor)};
%apply (TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) {(TYPE array[3][3][3])};
%apply (TYPE* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3)
- {(TYPE* array, int rows, int cols, int num)};
+ {(TYPE* array, int slices, int rows, int cols)};
%apply (int DIM1, int DIM2, int DIM3, TYPE* INPLACE_ARRAY3)
- {(int rows, int cols, int num, TYPE* array)};
+ {(int slices, int rows, int cols, TYPE* array)};
%apply (TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) {(TYPE lower[2][2][2])};
%apply (TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) {(TYPE upper[2][2][2])};
diff --git a/doc/swig/test/testArray.py b/doc/swig/test/testArray.py
index de744ce37..278a75f7a 100755
--- a/doc/swig/test/testArray.py
+++ b/doc/swig/test/testArray.py
@@ -69,7 +69,7 @@ class Array1TestCase(unittest.TestCase):
"Test Array1 resize method, array"
a = np.zeros((2*self.length,), dtype='l')
self.array1.resize(a)
- self.failUnless(len(self.array1) == len(a))
+ self.failUnless(len(self.array1) == a.size)
def testResizeBad(self):
"Test Array1 resize method, negative length"
@@ -177,11 +177,11 @@ class Array2TestCase(unittest.TestCase):
self.array2.resize(newRows, newCols)
self.failUnless(len(self.array2) == newRows * newCols)
- #def testResize1(self):
- # "Test Array2 resize method, array"
- # a = np.zeros((2*self.nrows, 2*self.ncols), dtype='l')
- # self.array2.resize(a)
- # self.failUnless(len(self.array2) == len(a))
+ def testResize1(self):
+ "Test Array2 resize method, array"
+ a = np.zeros((2*self.nrows, 2*self.ncols), dtype='l')
+ self.array2.resize(a)
+ self.failUnless(len(self.array2) == a.size)
def testResizeBad1(self):
"Test Array2 resize method, negative nrows"
diff --git a/doc/swig/test/testFortran.py b/doc/swig/test/testFortran.py
index ae7415d50..2175ad1bf 100644
--- a/doc/swig/test/testFortran.py
+++ b/doc/swig/test/testFortran.py
@@ -24,16 +24,19 @@ class FortranTestCase(unittest.TestCase):
self.typeStr = "double"
self.typeCode = "d"
- # Test (type* IN_FARRAY2, int DIM1, int DIM2) typemap
- def testSecondElementContiguous(self):
- "Test luSplit function with a Fortran-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- second = Fortran.__dict__[self.typeStr + "SecondElement"]
- matrix = np.arange(9).reshape(3, 3).astype(self.typeCode)
- self.assertEquals(second(matrix), 3)
+ # This test used to work before the update to avoid deprecated code. Now it
+ # doesn't work. As best I can tell, it never should have worked, so I am
+ # commenting it out. --WFS
+ # def testSecondElementContiguous(self):
+ # "Test Fortran matrix initialized from reshaped default array"
+ # print >>sys.stderr, self.typeStr, "... ",
+ # second = Fortran.__dict__[self.typeStr + "SecondElement"]
+ # matrix = np.arange(9).reshape(3, 3).astype(self.typeCode)
+ # self.assertEquals(second(matrix), 3)
+ # Test (type* IN_FARRAY2, int DIM1, int DIM2) typemap
def testSecondElementFortran(self):
- "Test luSplit function with a Fortran-array"
+ "Test Fortran matrix initialized from reshaped NumPy fortranarray"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
second = Fortran.__dict__[self.typeStr + "SecondElement"]
matrix = np.asfortranarray(np.arange(9).reshape(3, 3),
@@ -41,7 +44,7 @@ class FortranTestCase(unittest.TestCase):
self.assertEquals(second(matrix), 3)
def testSecondElementObject(self):
- "Test luSplit function with a Fortran-array"
+ "Test Fortran matrix initialized from nested list fortranarray"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
second = Fortran.__dict__[self.typeStr + "SecondElement"]
matrix = np.asfortranarray([[0,1,2],[3,4,5],[6,7,8]], self.typeCode)
diff --git a/doc/swig/test/testSuperTensor.py b/doc/swig/test/testSuperTensor.py
new file mode 100644
index 000000000..f4ae09e76
--- /dev/null
+++ b/doc/swig/test/testSuperTensor.py
@@ -0,0 +1,388 @@
+#! /usr/bin/env python
+from __future__ import division
+
+# System imports
+from distutils.util import get_platform
+from math import sqrt
+import os
+import sys
+import unittest
+
+# Import NumPy
+import numpy as np
+major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
+if major == 0: BadListError = TypeError
+else: BadListError = ValueError
+
+import SuperTensor
+
+######################################################################
+
+class SuperTensorTestCase(unittest.TestCase):
+
+ def __init__(self, methodName="runTests"):
+ unittest.TestCase.__init__(self, methodName)
+ self.typeStr = "double"
+ self.typeCode = "d"
+
+ # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
+ def testNorm(self):
+ "Test norm function"
+ print >>sys.stderr, self.typeStr, "... ",
+ norm = SuperTensor.__dict__[self.typeStr + "Norm"]
+ supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2))
+ #Note: cludge to get an answer of the same type as supertensor.
+ #Answer is simply sqrt(sum(supertensor*supertensor)/16)
+ answer = np.array([np.sqrt(np.sum(supertensor.astype('d')*supertensor)/16.)],dtype=self.typeCode)[0]
+ self.assertAlmostEqual(norm(supertensor), answer, 6)
+
+ # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
+ def testNormBadList(self):
+ "Test norm function with bad list"
+ print >>sys.stderr, self.typeStr, "... ",
+ norm = SuperTensor.__dict__[self.typeStr + "Norm"]
+ supertensor = [[[[0,"one"],[2,3]], [[3,"two"],[1,0]]],[[[0,"one"],[2,3]], [[3,"two"],[1,0]]]]
+ self.assertRaises(BadListError, norm, supertensor)
+
+ # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
+ def testNormWrongDim(self):
+ "Test norm function with wrong dimensions"
+ print >>sys.stderr, self.typeStr, "... ",
+ norm = SuperTensor.__dict__[self.typeStr + "Norm"]
+ supertensor = np.arange(2*2*2,dtype=self.typeCode).reshape((2,2,2))
+ self.assertRaises(TypeError, norm, supertensor)
+
+ # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
+ def testNormWrongSize(self):
+ "Test norm function with wrong size"
+ print >>sys.stderr, self.typeStr, "... ",
+ norm = SuperTensor.__dict__[self.typeStr + "Norm"]
+ supertensor = np.arange(3*2*2,dtype=self.typeCode).reshape((3,2,2))
+ self.assertRaises(TypeError, norm, supertensor)
+
+ # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
+ def testNormNonContainer(self):
+ "Test norm function with non-container"
+ print >>sys.stderr, self.typeStr, "... ",
+ norm = SuperTensor.__dict__[self.typeStr + "Norm"]
+ self.assertRaises(TypeError, norm, None)
+
+ # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testMax(self):
+ "Test max function"
+ print >>sys.stderr, self.typeStr, "... ",
+ max = SuperTensor.__dict__[self.typeStr + "Max"]
+ supertensor = [[[[1,2], [3,4]], [[5,6], [7,8]]],[[[1,2], [3,4]], [[5,6], [7,8]]]]
+ self.assertEquals(max(supertensor), 8)
+
+ # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testMaxBadList(self):
+ "Test max function with bad list"
+ print >>sys.stderr, self.typeStr, "... ",
+ max = SuperTensor.__dict__[self.typeStr + "Max"]
+ supertensor = [[[[1,"two"], [3,4]], [[5,"six"], [7,8]]],[[[1,"two"], [3,4]], [[5,"six"], [7,8]]]]
+ self.assertRaises(BadListError, max, supertensor)
+
+ # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testMaxNonContainer(self):
+ "Test max function with non-container"
+ print >>sys.stderr, self.typeStr, "... ",
+ max = SuperTensor.__dict__[self.typeStr + "Max"]
+ self.assertRaises(TypeError, max, None)
+
+ # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testMaxWrongDim(self):
+ "Test max function with wrong dimensions"
+ print >>sys.stderr, self.typeStr, "... ",
+ max = SuperTensor.__dict__[self.typeStr + "Max"]
+ self.assertRaises(TypeError, max, [0, -1, 2, -3])
+
+ # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
+ def testMin(self):
+ "Test min function"
+ print >>sys.stderr, self.typeStr, "... ",
+ min = SuperTensor.__dict__[self.typeStr + "Min"]
+ supertensor = [[[[9,8], [7,6]], [[5,4], [3,2]]],[[[9,8], [7,6]], [[5,4], [3,2]]]]
+ self.assertEquals(min(supertensor), 2)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
+ def testMinBadList(self):
+ "Test min function with bad list"
+ print >>sys.stderr, self.typeStr, "... ",
+ min = SuperTensor.__dict__[self.typeStr + "Min"]
+ supertensor = [[[["nine",8], [7,6]], [["five",4], [3,2]]],[[["nine",8], [7,6]], [["five",4], [3,2]]]]
+ self.assertRaises(BadListError, min, supertensor)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
+ def testMinNonContainer(self):
+ "Test min function with non-container"
+ print >>sys.stderr, self.typeStr, "... ",
+ min = SuperTensor.__dict__[self.typeStr + "Min"]
+ self.assertRaises(TypeError, min, True)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
+ def testMinWrongDim(self):
+ "Test min function with wrong dimensions"
+ print >>sys.stderr, self.typeStr, "... ",
+ min = SuperTensor.__dict__[self.typeStr + "Min"]
+ self.assertRaises(TypeError, min, [[1,3],[5,7]])
+
+ # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
+ def testScale(self):
+ "Test scale function"
+ print >>sys.stderr, self.typeStr, "... ",
+ scale = SuperTensor.__dict__[self.typeStr + "Scale"]
+ supertensor = np.arange(3*3*3*3,dtype=self.typeCode).reshape((3,3,3,3))
+ answer = supertensor.copy()*4
+ scale(supertensor,4)
+ self.assertEquals((supertensor == answer).all(), True)
+
+ # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
+ def testScaleWrongType(self):
+ "Test scale function with wrong type"
+ print >>sys.stderr, self.typeStr, "... ",
+ scale = SuperTensor.__dict__[self.typeStr + "Scale"]
+ supertensor = np.array([[[1,0,1], [0,1,0], [1,0,1]],
+ [[0,1,0], [1,0,1], [0,1,0]],
+ [[1,0,1], [0,1,0], [1,0,1]]],'c')
+ self.assertRaises(TypeError, scale, supertensor)
+
+ # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
+ def testScaleWrongDim(self):
+ "Test scale function with wrong dimensions"
+ print >>sys.stderr, self.typeStr, "... ",
+ scale = SuperTensor.__dict__[self.typeStr + "Scale"]
+ supertensor = np.array([[1,0,1], [0,1,0], [1,0,1],
+ [0,1,0], [1,0,1], [0,1,0]],self.typeCode)
+ self.assertRaises(TypeError, scale, supertensor)
+
+ # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
+ def testScaleWrongSize(self):
+ "Test scale function with wrong size"
+ print >>sys.stderr, self.typeStr, "... ",
+ scale = SuperTensor.__dict__[self.typeStr + "Scale"]
+ supertensor = np.array([[[1,0], [0,1], [1,0]],
+ [[0,1], [1,0], [0,1]],
+ [[1,0], [0,1], [1,0]]],self.typeCode)
+ self.assertRaises(TypeError, scale, supertensor)
+
+ # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
+ def testScaleNonArray(self):
+ "Test scale function with non-array"
+ print >>sys.stderr, self.typeStr, "... ",
+ scale = SuperTensor.__dict__[self.typeStr + "Scale"]
+ self.assertRaises(TypeError, scale, True)
+
+ # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testFloor(self):
+ "Test floor function"
+ print >>sys.stderr, self.typeStr, "... ",
+ supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2))
+ answer = supertensor.copy()
+ answer[answer < 4] = 4
+
+ floor = SuperTensor.__dict__[self.typeStr + "Floor"]
+ floor(supertensor,4)
+ np.testing.assert_array_equal(supertensor, answer)
+
+ # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testFloorWrongType(self):
+ "Test floor function with wrong type"
+ print >>sys.stderr, self.typeStr, "... ",
+ floor = SuperTensor.__dict__[self.typeStr + "Floor"]
+ supertensor = np.ones(2*2*2*2,dtype='c').reshape((2,2,2,2))
+ self.assertRaises(TypeError, floor, supertensor)
+
+ # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testFloorWrongDim(self):
+ "Test floor function with wrong type"
+ print >>sys.stderr, self.typeStr, "... ",
+ floor = SuperTensor.__dict__[self.typeStr + "Floor"]
+ supertensor = np.arange(2*2*2,dtype=self.typeCode).reshape((2,2,2))
+ self.assertRaises(TypeError, floor, supertensor)
+
+ # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
+ def testFloorNonArray(self):
+ "Test floor function with non-array"
+ print >>sys.stderr, self.typeStr, "... ",
+ floor = SuperTensor.__dict__[self.typeStr + "Floor"]
+ self.assertRaises(TypeError, floor, object)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
+ def testCeil(self):
+ "Test ceil function"
+ print >>sys.stderr, self.typeStr, "... ",
+ supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2))
+ answer = supertensor.copy()
+ answer[answer > 5] = 5
+ ceil = SuperTensor.__dict__[self.typeStr + "Ceil"]
+ ceil(supertensor,5)
+ np.testing.assert_array_equal(supertensor, answer)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
+ def testCeilWrongType(self):
+ "Test ceil function with wrong type"
+ print >>sys.stderr, self.typeStr, "... ",
+ ceil = SuperTensor.__dict__[self.typeStr + "Ceil"]
+ supertensor = np.ones(2*2*2*2,'c').reshape((2,2,2,2))
+ self.assertRaises(TypeError, ceil, supertensor)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
+ def testCeilWrongDim(self):
+ "Test ceil function with wrong dimensions"
+ print >>sys.stderr, self.typeStr, "... ",
+ ceil = SuperTensor.__dict__[self.typeStr + "Ceil"]
+ supertensor = np.arange(2*2*2,dtype=self.typeCode).reshape((2,2,2))
+ self.assertRaises(TypeError, ceil, supertensor)
+
+ # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
+ def testCeilNonArray(self):
+ "Test ceil function with non-array"
+ print >>sys.stderr, self.typeStr, "... ",
+ ceil = SuperTensor.__dict__[self.typeStr + "Ceil"]
+ supertensor = np.arange(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2)).tolist()
+ self.assertRaises(TypeError, ceil, supertensor)
+
+ # Test (type ARGOUT_ARRAY3[ANY][ANY][ANY]) typemap
+ def testLUSplit(self):
+ "Test luSplit function"
+ print >>sys.stderr, self.typeStr, "... ",
+ luSplit = SuperTensor.__dict__[self.typeStr + "LUSplit"]
+ supertensor = np.ones(2*2*2*2,dtype=self.typeCode).reshape((2,2,2,2))
+ answer_upper = [[[[0, 0], [0, 1]], [[0, 1], [1, 1]]], [[[0, 1], [1, 1]], [[1, 1], [1, 1]]]]
+ answer_lower = [[[[1, 1], [1, 0]], [[1, 0], [0, 0]]], [[[1, 0], [0, 0]], [[0, 0], [0, 0]]]]
+ lower, upper = luSplit(supertensor)
+ self.assertEquals((lower == answer_lower).all(), True)
+ self.assertEquals((upper == answer_upper).all(), True)
+
+######################################################################
+
+class scharTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "schar"
+ self.typeCode = "b"
+ #self.result = int(self.result)
+
+######################################################################
+
+class ucharTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "uchar"
+ self.typeCode = "B"
+ #self.result = int(self.result)
+
+######################################################################
+
+class shortTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "short"
+ self.typeCode = "h"
+ #self.result = int(self.result)
+
+######################################################################
+
+class ushortTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "ushort"
+ self.typeCode = "H"
+ #self.result = int(self.result)
+
+######################################################################
+
+class intTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "int"
+ self.typeCode = "i"
+ #self.result = int(self.result)
+
+######################################################################
+
+class uintTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "uint"
+ self.typeCode = "I"
+ #self.result = int(self.result)
+
+######################################################################
+
+class longTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "long"
+ self.typeCode = "l"
+ #self.result = int(self.result)
+
+######################################################################
+
+class ulongTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "ulong"
+ self.typeCode = "L"
+ #self.result = int(self.result)
+
+######################################################################
+
+class longLongTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "longLong"
+ self.typeCode = "q"
+ #self.result = int(self.result)
+
+######################################################################
+
+class ulongLongTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "ulongLong"
+ self.typeCode = "Q"
+ #self.result = int(self.result)
+
+######################################################################
+
+class floatTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "float"
+ self.typeCode = "f"
+
+######################################################################
+
+class doubleTestCase(SuperTensorTestCase):
+ def __init__(self, methodName="runTest"):
+ SuperTensorTestCase.__init__(self, methodName)
+ self.typeStr = "double"
+ self.typeCode = "d"
+
+######################################################################
+
+if __name__ == "__main__":
+
+ # Build the test suite
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite( scharTestCase))
+ suite.addTest(unittest.makeSuite( ucharTestCase))
+ suite.addTest(unittest.makeSuite( shortTestCase))
+ suite.addTest(unittest.makeSuite( ushortTestCase))
+ suite.addTest(unittest.makeSuite( intTestCase))
+ suite.addTest(unittest.makeSuite( uintTestCase))
+ suite.addTest(unittest.makeSuite( longTestCase))
+ suite.addTest(unittest.makeSuite( ulongTestCase))
+ suite.addTest(unittest.makeSuite( longLongTestCase))
+ suite.addTest(unittest.makeSuite(ulongLongTestCase))
+ suite.addTest(unittest.makeSuite( floatTestCase))
+ suite.addTest(unittest.makeSuite( doubleTestCase))
+
+ # Execute the test suite
+ print "Testing 4D Functions of Module SuperTensor"
+ print "NumPy version", np.__version__
+ print
+ result = unittest.TextTestRunner(verbosity=2).run(suite)
+ sys.exit(len(result.errors) + len(result.failures))