summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-03-13 11:56:50 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-03-13 11:56:50 -0600
commit9c4602f98096abed5632d5fd1f12549a2c5b360c (patch)
treeb154e4d7a7fff6e491216b2e3750d238645903e2 /doc
parentdfe6c7ed74c087c0deabfd4f7a50224498840838 (diff)
parentf151004567f61c1a613dd78a87521adf795a4942 (diff)
downloadnumpy-9c4602f98096abed5632d5fd1f12549a2c5b360c.tar.gz
Merge pull request #4487 from charris/move-swig-to-tools-directory
Move swig to tools directory
Diffstat (limited to 'doc')
-rw-r--r--doc/release/1.9.0-notes.rst8
-rw-r--r--doc/source/user/c-info.python-as-glue.rst2
-rw-r--r--doc/swig/Makefile31
-rw-r--r--doc/swig/README135
-rw-r--r--doc/swig/numpy.i3085
-rw-r--r--doc/swig/pyfragments.swg119
-rw-r--r--doc/swig/test/Array.i102
-rw-r--r--doc/swig/test/Array1.cxx131
-rw-r--r--doc/swig/test/Array1.h55
-rw-r--r--doc/swig/test/Array2.cxx168
-rw-r--r--doc/swig/test/Array2.h63
-rw-r--r--doc/swig/test/Farray.cxx122
-rw-r--r--doc/swig/test/Farray.h56
-rw-r--r--doc/swig/test/Farray.i73
-rw-r--r--doc/swig/test/Fortran.cxx24
-rw-r--r--doc/swig/test/Fortran.h21
-rw-r--r--doc/swig/test/Fortran.i36
-rw-r--r--doc/swig/test/Makefile34
-rw-r--r--doc/swig/test/Matrix.cxx112
-rw-r--r--doc/swig/test/Matrix.h52
-rw-r--r--doc/swig/test/Matrix.i45
-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.cxx131
-rw-r--r--doc/swig/test/Tensor.h52
-rw-r--r--doc/swig/test/Tensor.i49
-rw-r--r--doc/swig/test/Vector.cxx100
-rw-r--r--doc/swig/test/Vector.h58
-rw-r--r--doc/swig/test/Vector.i47
-rwxr-xr-xdoc/swig/test/setup.py64
-rwxr-xr-xdoc/swig/test/testArray.py284
-rwxr-xr-xdoc/swig/test/testFarray.py159
-rw-r--r--doc/swig/test/testFortran.py173
-rwxr-xr-xdoc/swig/test/testMatrix.py362
-rw-r--r--doc/swig/test/testSuperTensor.py388
-rwxr-xr-xdoc/swig/test/testTensor.py402
-rwxr-xr-xdoc/swig/test/testVector.py381
38 files changed, 7 insertions, 7364 deletions
diff --git a/doc/release/1.9.0-notes.rst b/doc/release/1.9.0-notes.rst
index 2e457ad84..c8b08b34d 100644
--- a/doc/release/1.9.0-notes.rst
+++ b/doc/release/1.9.0-notes.rst
@@ -46,8 +46,8 @@ to an array via ``np.array``.
If the ``overwrite_input`` option is used the input is only partially
instead of fully sorted.
-``npy_3kcompat.h`` header change
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The ``npy_3kcompat.h`` header changed
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The unused ``simple_capsule_dtor`` function has been removed from
``npy_3kcompat.h``. Note that this header is not meant to be used outside
of numpy; other projects should be using their own copy of this file when
@@ -65,6 +65,10 @@ ndarray.tofile exception type
All ``tofile`` exceptions are now ``IOError``, some were previously
``ValueError``.
+The ``doc/swig`` directory moved
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The ``doc/swig`` directory has been moved to ``tools/swig``.
+
New Features
============
diff --git a/doc/source/user/c-info.python-as-glue.rst b/doc/source/user/c-info.python-as-glue.rst
index 6ce266859..985d478e0 100644
--- a/doc/source/user/c-info.python-as-glue.rst
+++ b/doc/source/user/c-info.python-as-glue.rst
@@ -1385,7 +1385,7 @@ Simplified Wrapper and Interface Generator (SWIG) is an old and fairly
stable method for wrapping C/C++-libraries to a large variety of other
languages. It does not specifically understand NumPy arrays but can be
made useable with NumPy through the use of typemaps. There are some
-sample typemaps in the numpy/doc/swig directory under numpy.i along
+sample typemaps in the numpy/tools/swig directory under numpy.i together
with an example module that makes use of them. SWIG excels at wrapping
large C/C++ libraries because it can (almost) parse their headers and
auto-produce an interface. Technically, you need to generate a ``.i``
diff --git a/doc/swig/Makefile b/doc/swig/Makefile
deleted file mode 100644
index 0478ac76f..000000000
--- a/doc/swig/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# List all of the subdirectories here for recursive make
-SUBDIRS = test
-
-# Default target
-.PHONY : default
-default:
- @echo "There is no default make target for this Makefile"
- @echo "Valid make targets are:"
- @echo " test - Compile and run tests of numpy.i"
- @echo " doc - Generate numpy.i documentation"
- @echo " all - make test + doc"
- @echo " clean - Remove generated files recursively"
-
-# Target all
-.PHONY : all
-all: $(SUBDIRS)
-
-# Target test
-.PHONY : test
-test:
- cd $@ && make $@
-
-# Target clean
-.PHONY : clean
-clean:
- @for dir in $(SUBDIRS); do \
- echo ; \
- echo Running \'make clean\' in $$dir; \
- cd $$dir && make clean && cd ..; \
- done; \
- echo
diff --git a/doc/swig/README b/doc/swig/README
deleted file mode 100644
index df5dbfc47..000000000
--- a/doc/swig/README
+++ /dev/null
@@ -1,135 +0,0 @@
-Notes for the numpy/doc/swig directory
-======================================
-
-This set of files is for developing and testing file numpy.i, which is
-intended to be a set of typemaps for helping SWIG interface between C
-and C++ code that uses C arrays and the python module NumPy. It is
-ultimately hoped that numpy.i will be included as part of the SWIG
-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.
-
-Testing
--------
-The tests are a good example of what we are trying to do with numpy.i.
-The files related to testing are are in the test subdirectory::
-
- Vector.h
- Vector.cxx
- Vector.i
- testVector.py
-
- Matrix.h
- Matrix.cxx
- Matrix.i
- testMatrix.py
-
- Tensor.h
- Tensor.cxx
- 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::
-
- (type IN_ARRAY1[ANY])
- (type* IN_ARRAY1, int DIM1)
- (int DIM1, type* IN_ARRAY1)
-
- (type INPLACE_ARRAY1[ANY])
- (type* INPLACE_ARRAY1, int DIM1)
- (int DIM1, type* INPLACE_ARRAY1)
-
- (type ARGOUT_ARRAY1[ANY])
- (type* ARGOUT_ARRAY1, int DIM1)
- (int DIM1, type* ARGOUT_ARRAY1)
-
-Matrix.h::
-
- (type IN_ARRAY2[ANY][ANY])
- (type* IN_ARRAY2, int DIM1, int DIM2)
- (int DIM1, int DIM2, type* IN_ARRAY2)
-
- (type INPLACE_ARRAY2[ANY][ANY])
- (type* INPLACE_ARRAY2, int DIM1, int DIM2)
- (int DIM1, int DIM2, type* INPLACE_ARRAY2)
-
- (type ARGOUT_ARRAY2[ANY][ANY])
-
-Tensor.h::
-
- (type IN_ARRAY3[ANY][ANY][ANY])
- (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3)
- (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3)
-
- (type INPLACE_ARRAY3[ANY][ANY][ANY])
- (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3)
- (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3)
-
- (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,
-and DIM4).
-
-The objective for the IN_ARRAY signatures is for SWIG to generate
-python wrappers that take a container that constitutes a valid
-argument to the numpy array constructor, and can be used to build an
-array of type "type". Currently, types "signed char", "unsigned
-char", "short", "unsigned short", "int", "unsigned int", "long",
-"unsigned long", "long long", "unsigned long long", "float", and
-"double" are supported and tested.
-
-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 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 _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").
-
-To build and run the test code, simply execute from the shell::
-
- $ make test
diff --git a/doc/swig/numpy.i b/doc/swig/numpy.i
deleted file mode 100644
index 529725479..000000000
--- a/doc/swig/numpy.i
+++ /dev/null
@@ -1,3085 +0,0 @@
-/* -*- C -*- (not really, but good for syntax highlighting) */
-#ifdef SWIGPYTHON
-
-%{
-#ifndef SWIG_FILE_WITH_INIT
-#define NO_IMPORT_ARRAY
-#endif
-#include "stdio.h"
-#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
-#include <numpy/arrayobject.h>
-%}
-
-/**********************************************************************/
-
-%fragment("NumPy_Backward_Compatibility", "header")
-{
-%#if NPY_API_VERSION < 0x00000007
-%#define NPY_ARRAY_DEFAULT NPY_DEFAULT
-%#define NPY_ARRAY_FARRAY NPY_FARRAY
-%#define NPY_FORTRANORDER NPY_FORTRAN
-%#endif
-}
-
-/**********************************************************************/
-
-/* The following code originally appeared in
- * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was
- * translated from C++ to C by John Hunter. Bill Spotz has modified
- * it to fix some minor bugs, upgrade from Numeric to numpy (all
- * versions), add some comments and functionality, and convert from
- * direct code insertion to SWIG fragments.
- */
-
-%fragment("NumPy_Macros", "header")
-{
-/* Macros to extract array attributes.
- */
-%#if NPY_API_VERSION < 0x00000007
-%#define is_array(a) ((a) && PyArray_Check((PyArrayObject*)a))
-%#define array_type(a) (int)(PyArray_TYPE((PyArrayObject*)a))
-%#define array_numdims(a) (((PyArrayObject*)a)->nd)
-%#define array_dimensions(a) (((PyArrayObject*)a)->dimensions)
-%#define array_size(a,i) (((PyArrayObject*)a)->dimensions[i])
-%#define array_strides(a) (((PyArrayObject*)a)->strides)
-%#define array_stride(a,i) (((PyArrayObject*)a)->strides[i])
-%#define array_data(a) (((PyArrayObject*)a)->data)
-%#define array_descr(a) (((PyArrayObject*)a)->descr)
-%#define array_flags(a) (((PyArrayObject*)a)->flags)
-%#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f
-%#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")
-{
- /* Given a PyObject, return a string describing its type.
- */
- const char* pytype_string(PyObject* py_obj)
- {
- if (py_obj == NULL ) return "C NULL value";
- if (py_obj == Py_None ) return "Python None" ;
- if (PyCallable_Check(py_obj)) return "callable" ;
- if (PyString_Check( py_obj)) return "string" ;
- if (PyInt_Check( py_obj)) return "int" ;
- if (PyFloat_Check( py_obj)) return "float" ;
- if (PyDict_Check( py_obj)) return "dict" ;
- if (PyList_Check( py_obj)) return "list" ;
- if (PyTuple_Check( py_obj)) return "tuple" ;
-%#if PY_MAJOR_VERSION < 3
- if (PyFile_Check( py_obj)) return "file" ;
- if (PyModule_Check( py_obj)) return "module" ;
- if (PyInstance_Check(py_obj)) return "instance" ;
-%#endif
-
- return "unkown type";
- }
-
- /* Given a NumPy typecode, return a string describing the type.
- */
- const char* typecode_string(int typecode)
- {
- static const char* type_names[25] = {"bool",
- "byte",
- "unsigned byte",
- "short",
- "unsigned short",
- "int",
- "unsigned int",
- "long",
- "unsigned long",
- "long long",
- "unsigned long long",
- "float",
- "double",
- "long double",
- "complex float",
- "complex double",
- "complex long double",
- "object",
- "string",
- "unicode",
- "void",
- "ntypes",
- "notype",
- "char",
- "unknown"};
- return typecode < 24 ? type_names[typecode] : type_names[24];
- }
-
- /* Make sure input has correct numpy type. This now just calls
- PyArray_EquivTypenums().
- */
- int type_match(int actual_type,
- int desired_type)
- {
- return PyArray_EquivTypenums(actual_type, desired_type);
- }
-
-%#ifdef SWIGPY_USE_CAPSULE
- void free_cap(PyObject * cap)
- {
- void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME);
- if (array != NULL) free(array);
- }
-%#endif
-
-
-}
-
-/**********************************************************************/
-
-%fragment("NumPy_Object_to_Array",
- "header",
- fragment="NumPy_Backward_Compatibility",
- fragment="NumPy_Macros",
- fragment="NumPy_Utilities")
-{
- /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
- * legal. If not, set the python error string appropriately and
- * return NULL.
- */
- PyArrayObject* obj_to_array_no_conversion(PyObject* input,
- int typecode)
- {
- PyArrayObject* ary = NULL;
- if (is_array(input) && (typecode == NPY_NOTYPE ||
- PyArray_EquivTypenums(array_type(input), typecode)))
- {
- ary = (PyArrayObject*) input;
- }
- else if is_array(input)
- {
- const char* desired_type = typecode_string(typecode);
- const char* actual_type = typecode_string(array_type(input));
- PyErr_Format(PyExc_TypeError,
- "Array of type '%s' required. Array of type '%s' given",
- desired_type, actual_type);
- ary = NULL;
- }
- else
- {
- const char* desired_type = typecode_string(typecode);
- const char* actual_type = pytype_string(input);
- PyErr_Format(PyExc_TypeError,
- "Array of type '%s' required. A '%s' was given",
- desired_type,
- actual_type);
- ary = NULL;
- }
- return ary;
- }
-
- /* Convert the given PyObject to a NumPy array with the given
- * typecode. On success, return a valid PyArrayObject* with the
- * correct type. On failure, the python error string will be set and
- * the routine returns NULL.
- */
- PyArrayObject* obj_to_array_allow_conversion(PyObject* input,
- int typecode,
- int* is_new_object)
- {
- PyArrayObject* ary = NULL;
- PyObject* py_obj;
- if (is_array(input) && (typecode == NPY_NOTYPE ||
- PyArray_EquivTypenums(array_type(input),typecode)))
- {
- ary = (PyArrayObject*) input;
- *is_new_object = 0;
- }
- else
- {
- py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_ARRAY_DEFAULT);
- /* If NULL, PyArray_FromObject will have set python error value.*/
- ary = (PyArrayObject*) py_obj;
- *is_new_object = 1;
- }
- return ary;
- }
-
- /* Given a PyArrayObject, check to see if it is contiguous. If so,
- * return the input pointer and flag it as not a new object. If it is
- * not contiguous, create a new PyArrayObject using the original data,
- * flag it as a new object and return the pointer.
- */
- PyArrayObject* make_contiguous(PyArrayObject* ary,
- int* is_new_object,
- int min_dims,
- int max_dims)
- {
- PyArrayObject* result;
- if (array_is_contiguous(ary))
- {
- result = ary;
- *is_new_object = 0;
- }
- else
- {
- result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
- array_type(ary),
- min_dims,
- max_dims);
- *is_new_object = 1;
- }
- return result;
- }
-
- /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
- * If so, return the input pointer, but do not flag it as not a new
- * object. If it is not Fortran-contiguous, create a new
- * PyArrayObject using the original data, flag it as a new object
- * and return the pointer.
- */
- PyArrayObject* make_fortran(PyArrayObject* ary,
- int* is_new_object)
- {
- PyArrayObject* result;
- if (array_is_fortran(ary))
- {
- result = ary;
- *is_new_object = 0;
- }
- else
- {
- Py_INCREF(array_descr(ary));
- result = (PyArrayObject*) PyArray_FromArray(ary,
- array_descr(ary),
- NPY_FORTRANORDER);
- *is_new_object = 1;
- }
- return result;
- }
-
- /* Convert a given PyObject to a contiguous PyArrayObject of the
- * specified type. If the input object is not a contiguous
- * PyArrayObject, a new one will be created and the new object flag
- * will be set.
- */
- PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
- int typecode,
- int* is_new_object)
- {
- int is_new1 = 0;
- int is_new2 = 0;
- PyArrayObject* ary2;
- PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
- typecode,
- &is_new1);
- if (ary1)
- {
- ary2 = make_contiguous(ary1, &is_new2, 0, 0);
- if ( is_new1 && is_new2)
- {
- Py_DECREF(ary1);
- }
- ary1 = ary2;
- }
- *is_new_object = is_new1 || is_new2;
- return ary1;
- }
-
- /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
- * specified type. If the input object is not a Fortran-ordered
- * PyArrayObject, a new one will be created and the new object flag
- * will be set.
- */
- PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
- int typecode,
- int* is_new_object)
- {
- int is_new1 = 0;
- int is_new2 = 0;
- PyArrayObject* ary2;
- PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
- typecode,
- &is_new1);
- if (ary1)
- {
- ary2 = make_fortran(ary1, &is_new2);
- if (is_new1 && is_new2)
- {
- Py_DECREF(ary1);
- }
- ary1 = ary2;
- }
- *is_new_object = is_new1 || is_new2;
- return ary1;
- }
-} /* end fragment */
-
-/**********************************************************************/
-
-%fragment("NumPy_Array_Requirements",
- "header",
- fragment="NumPy_Backward_Compatibility",
- fragment="NumPy_Macros")
-{
- /* Test whether a python object is contiguous. If array is
- * contiguous, return 1. Otherwise, set the python error string and
- * return 0.
- */
- int require_contiguous(PyArrayObject* ary)
- {
- int contiguous = 1;
- if (!array_is_contiguous(ary))
- {
- PyErr_SetString(PyExc_TypeError,
- "Array must be contiguous. A non-contiguous array was given");
- contiguous = 0;
- }
- return contiguous;
- }
-
- /* Require that a numpy array is not byte-swapped. If the array is
- * not byte-swapped, return 1. Otherwise, set the python error string
- * and return 0.
- */
- int require_native(PyArrayObject* ary)
- {
- int native = 1;
- if (!array_is_native(ary))
- {
- PyErr_SetString(PyExc_TypeError,
- "Array must have native byteorder. "
- "A byte-swapped array was given");
- native = 0;
- }
- return native;
- }
-
- /* Require the given PyArrayObject to have a specified number of
- * dimensions. If the array has the specified number of dimensions,
- * return 1. Otherwise, set the python error string and return 0.
- */
- int require_dimensions(PyArrayObject* ary,
- int exact_dimensions)
- {
- int success = 1;
- if (array_numdims(ary) != exact_dimensions)
- {
- PyErr_Format(PyExc_TypeError,
- "Array must have %d dimensions. Given array has %d dimensions",
- exact_dimensions,
- array_numdims(ary));
- success = 0;
- }
- return success;
- }
-
- /* Require the given PyArrayObject to have one of a list of specified
- * number of dimensions. If the array has one of the specified number
- * of dimensions, return 1. Otherwise, set the python error string
- * and return 0.
- */
- int require_dimensions_n(PyArrayObject* ary,
- int* exact_dimensions,
- int n)
- {
- int success = 0;
- int i;
- char dims_str[255] = "";
- char s[255];
- for (i = 0; i < n && !success; i++)
- {
- if (array_numdims(ary) == exact_dimensions[i])
- {
- success = 1;
- }
- }
- if (!success)
- {
- for (i = 0; i < n-1; i++)
- {
- sprintf(s, "%d, ", exact_dimensions[i]);
- strcat(dims_str,s);
- }
- sprintf(s, " or %d", exact_dimensions[n-1]);
- strcat(dims_str,s);
- PyErr_Format(PyExc_TypeError,
- "Array must have %s dimensions. Given array has %d dimensions",
- dims_str,
- array_numdims(ary));
- }
- return success;
- }
-
- /* Require the given PyArrayObject to have a specified shape. If the
- * array has the specified shape, return 1. Otherwise, set the python
- * error string and return 0.
- */
- int require_size(PyArrayObject* ary,
- npy_intp* size,
- int n)
- {
- int i;
- int success = 1;
- int len;
- char desired_dims[255] = "[";
- char s[255];
- char actual_dims[255] = "[";
- for(i=0; i < n;i++)
- {
- if (size[i] != -1 && size[i] != array_size(ary,i))
- {
- success = 0;
- }
- }
- if (!success)
- {
- for (i = 0; i < n; i++)
- {
- if (size[i] == -1)
- {
- sprintf(s, "*,");
- }
- else
- {
- sprintf(s, "%ld,", (long int)size[i]);
- }
- strcat(desired_dims,s);
- }
- len = strlen(desired_dims);
- desired_dims[len-1] = ']';
- for (i = 0; i < n; i++)
- {
- sprintf(s, "%ld,", (long int)array_size(ary,i));
- strcat(actual_dims,s);
- }
- len = strlen(actual_dims);
- actual_dims[len-1] = ']';
- PyErr_Format(PyExc_TypeError,
- "Array must have shape of %s. Given array has shape of %s",
- desired_dims,
- actual_dims);
- }
- return success;
- }
-
- /* Require the given PyArrayObject to to be Fortran ordered. If the
- * the PyArrayObject is already Fortran ordered, do nothing. Else,
- * set the Fortran ordering flag and recompute the strides.
- */
- int require_fortran(PyArrayObject* ary)
- {
- int success = 1;
- int nd = array_numdims(ary);
- int i;
- npy_intp * strides = array_strides(ary);
- if (array_is_fortran(ary)) return success;
- /* Set the Fortran ordered flag */
- array_enableflags(ary,NPY_ARRAY_FARRAY);
- /* Recompute the strides */
- strides[0] = strides[nd-1];
- for (i=1; i < nd; ++i)
- strides[i] = strides[i-1] * array_size(ary,i-1);
- return success;
- }
-}
-
-/* Combine all NumPy fragments into one for convenience */
-%fragment("NumPy_Fragments",
- "header",
- fragment="NumPy_Backward_Compatibility",
- fragment="NumPy_Macros",
- fragment="NumPy_Utilities",
- fragment="NumPy_Object_to_Array",
- fragment="NumPy_Array_Requirements")
-{
-}
-
-/* End John Hunter translation (with modifications by Bill Spotz)
- */
-
-/* %numpy_typemaps() macro
- *
- * This macro defines a family of 74 typemaps that allow C arguments
- * of the form
- *
- * 1. (DATA_TYPE IN_ARRAY1[ANY])
- * 2. (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
- * 3. (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
- *
- * 4. (DATA_TYPE IN_ARRAY2[ANY][ANY])
- * 5. (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * 6. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
- * 7. (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * 8. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
- *
- * 9. (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
- * 10. (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * 11. (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * 12. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
- * 13. (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * 14. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
- *
- * 15. (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
- * 16. (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- * 17. (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- * 18. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
- * 19. (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- * 20. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
- *
- * 21. (DATA_TYPE INPLACE_ARRAY1[ANY])
- * 22. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
- * 23. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
- *
- * 24. (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
- * 25. (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * 26. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
- * 27. (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- * 28. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
- *
- * 29. (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
- * 30. (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * 31. (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * 32. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
- * 33. (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- * 34. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
- *
- * 35. (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
- * 36. (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- * 37. (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- * 38. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
- * 39. (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- * 40. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
- *
- * 41. (DATA_TYPE ARGOUT_ARRAY1[ANY])
- * 42. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
- * 43. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
- *
- * 44. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
- *
- * 45. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
- *
- * 46. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
- *
- * 47. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
- * 48. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
- *
- * 49. (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- * 50. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
- * 51. (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- * 52. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
- *
- * 53. (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- * 54. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
- * 55. (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- * 56. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
- *
- * 57. (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
- * 58. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
- * 59. (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
- * 60. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
- *
- * 61. (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
- * 62. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
- *
- * 63. (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- * 64. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
- * 65. (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- * 66. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
- *
- * 67. (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- * 68. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
- * 69. (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
- * 70. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
- *
- * 71. (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
- * 72. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
- * 73. (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
- * 74. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
- *
- * where "DATA_TYPE" is any type supported by the NumPy module, and
- * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
- * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
- * that the "FARRAY" typemaps expect Fortran ordering of
- * multidimensional arrays. In python, the dimensions will not need
- * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
- * typemaps). The IN_ARRAYs can be a numpy array or any sequence that
- * can be converted to a numpy array of the specified type. The
- * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The
- * ARGOUT_ARRAYs will be returned as new numpy arrays of the
- * appropriate type.
- *
- * These typemaps can be applied to existing functions using the
- * %apply directive. For example:
- *
- * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
- * double prod(double* series, int length);
- *
- * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
- * {(int rows, int cols, double* matrix )};
- * void floor(int rows, int cols, double* matrix, double f);
- *
- * %apply (double IN_ARRAY3[ANY][ANY][ANY])
- * {(double tensor[2][2][2] )};
- * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
- * {(double low[2][2][2] )};
- * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
- * {(double upp[2][2][2] )};
- * void luSplit(double tensor[2][2][2],
- * double low[2][2][2],
- * double upp[2][2][2] );
- *
- * or directly with
- *
- * double prod(double* IN_ARRAY1, int DIM1);
- *
- * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
- *
- * void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
- * double ARGOUT_ARRAY3[ANY][ANY][ANY],
- * double ARGOUT_ARRAY3[ANY][ANY][ANY]);
- */
-
-%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
-
-/************************/
-/* Input Array Typemaps */
-/************************/
-
-/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE IN_ARRAY1[ANY])
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE IN_ARRAY1[ANY])
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[1] = { $1_dim0 };
- array = obj_to_array_contiguous_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 1) ||
- !require_size(array, size, 1)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(freearg)
- (DATA_TYPE IN_ARRAY1[ANY])
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[1] = { -1 };
- array = obj_to_array_contiguous_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 1) ||
- !require_size(array, size, 1)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[1] = {-1};
- array = obj_to_array_contiguous_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 1) ||
- !require_size(array, size, 1)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DATA_TYPE*) array_data(array);
-}
-%typemap(freearg)
- (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE IN_ARRAY2[ANY][ANY])
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE IN_ARRAY2[ANY][ANY])
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[2] = { $1_dim0, $1_dim1 };
- array = obj_to_array_contiguous_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 2) ||
- !require_size(array, size, 2)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(freearg)
- (DATA_TYPE IN_ARRAY2[ANY][ANY])
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[2] = { -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 2) ||
- !require_size(array, size, 2)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[2] = { -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 2) ||
- !require_size(array, size, 2)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DATA_TYPE*) array_data(array);
-}
-%typemap(freearg)
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[2] = { -1, -1 };
- array = obj_to_array_fortran_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 2) ||
- !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[2] = { -1, -1 };
- array = obj_to_array_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;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DATA_TYPE*) array_data(array);
-}
-%typemap(freearg)
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
- array = obj_to_array_contiguous_allow_conversion($input,
- DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 3) ||
- !require_size(array, size, 3)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(freearg)
- (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[3] = { -1, -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 3) ||
- !require_size(array, size, 3)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- /* for now, only concerned with lists */
- $1 = PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL)
-{
- npy_intp size[2] = { -1, -1 };
- PyArrayObject* temp_array;
- Py_ssize_t i;
- int is_new_object;
-
- /* length of the list */
- $2 = PyList_Size($input);
-
- /* the arrays */
- array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
- object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
- is_new_object_array = (int *)calloc($2,sizeof(int));
-
- if (array == NULL || object_array == NULL || is_new_object_array == NULL)
- {
- SWIG_fail;
- }
-
- for (i=0; i<$2; i++)
- {
- temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object);
-
- /* the new array must be stored so that it can be destroyed in freearg */
- object_array[i] = temp_array;
- is_new_object_array[i] = is_new_object;
-
- if (!temp_array || !require_dimensions(temp_array, 2)) SWIG_fail;
-
- /* store the size of the first array in the list, then use that for comparison. */
- if (i == 0)
- {
- size[0] = array_size(temp_array,0);
- size[1] = array_size(temp_array,1);
- }
-
- if (!require_size(temp_array, size, 2)) SWIG_fail;
-
- array[i] = (DATA_TYPE*) array_data(temp_array);
- }
-
- $1 = (DATA_TYPE**) array;
- $3 = (DIM_TYPE) size[0];
- $4 = (DIM_TYPE) size[1];
-}
-%typemap(freearg)
- (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- Py_ssize_t i;
-
- if (array$argnum!=NULL) free(array$argnum);
-
- /*freeing the individual arrays if needed */
- if (object_array$argnum!=NULL)
- {
- if (is_new_object_array$argnum!=NULL)
- {
- for (i=0; i<$2; i++)
- {
- if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i])
- { Py_DECREF(object_array$argnum[i]); }
- }
- free(is_new_object_array$argnum);
- }
- free(object_array$argnum);
- }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
- * DATA_TYPE* IN_ARRAY3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[3] = { -1, -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 3) ||
- !require_size(array, size, 3)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DATA_TYPE*) array_data(array);
-}
-%typemap(freearg)
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[3] = { -1, -1, -1 };
- array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 3) ||
- !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
- * DATA_TYPE* IN_FARRAY3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[3] = { -1, -1, -1 };
- array = obj_to_array_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;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DATA_TYPE*) array_data(array);
-}
-%typemap(freearg)
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3};
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 4) ||
- !require_size(array, size, 4)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(freearg)
- (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3, DIM_TYPE DIM4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[4] = { -1, -1, -1, -1 };
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 4) ||
- !require_size(array, size, 4)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
- $5 = (DIM_TYPE) array_size(array,3);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3, DIM_TYPE DIM4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- /* for now, only concerned with lists */
- $1 = PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL)
-{
- npy_intp size[3] = { -1, -1, -1 };
- PyArrayObject* temp_array;
- Py_ssize_t i;
- int is_new_object;
-
- /* length of the list */
- $2 = PyList_Size($input);
-
- /* the arrays */
- array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
- object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
- is_new_object_array = (int *)calloc($2,sizeof(int));
-
- if (array == NULL || object_array == NULL || is_new_object_array == NULL)
- {
- SWIG_fail;
- }
-
- for (i=0; i<$2; i++)
- {
- temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object);
-
- /* the new array must be stored so that it can be destroyed in freearg */
- object_array[i] = temp_array;
- is_new_object_array[i] = is_new_object;
-
- if (!temp_array || !require_dimensions(temp_array, 3)) SWIG_fail;
-
- /* store the size of the first array in the list, then use that for comparison. */
- if (i == 0)
- {
- size[0] = array_size(temp_array,0);
- size[1] = array_size(temp_array,1);
- size[2] = array_size(temp_array,2);
- }
-
- if (!require_size(temp_array, size, 3)) SWIG_fail;
-
- array[i] = (DATA_TYPE*) array_data(temp_array);
- }
-
- $1 = (DATA_TYPE**) array;
- $3 = (DIM_TYPE) size[0];
- $4 = (DIM_TYPE) size[1];
- $5 = (DIM_TYPE) size[2];
-}
-%typemap(freearg)
- (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- Py_ssize_t i;
-
- if (array$argnum!=NULL) free(array$argnum);
-
- /*freeing the individual arrays if needed */
- if (object_array$argnum!=NULL)
- {
- if (is_new_object_array$argnum!=NULL)
- {
- for (i=0; i<$2; i++)
- {
- if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i])
- { Py_DECREF(object_array$argnum[i]); }
- }
- free(is_new_object_array$argnum);
- }
- free(object_array$argnum);
- }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
- * DATA_TYPE* IN_ARRAY4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[4] = { -1, -1, -1 , -1};
- array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 4) ||
- !require_size(array, size, 4)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DIM_TYPE) array_size(array,3);
- $5 = (DATA_TYPE*) array_data(array);
-}
-%typemap(freearg)
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3, DIM_TYPE DIM4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[4] = { -1, -1, -1, -1 };
- array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
- &is_new_object);
- if (!array || !require_dimensions(array, 4) ||
- !require_size(array, size, 4) | !require_fortran(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
- $5 = (DIM_TYPE) array_size(array,3);
-}
-%typemap(freearg)
- (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- if (is_new_object$argnum && array$argnum)
- { Py_DECREF(array$argnum); }
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
- * DATA_TYPE* IN_FARRAY4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
-{
- $1 = is_array($input) || PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
- (PyArrayObject* array=NULL, int is_new_object=0)
-{
- npy_intp size[4] = { -1, -1, -1 , -1 };
- array = obj_to_array_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 */
-/***************************/
-
-/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE INPLACE_ARRAY1[ANY])
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE INPLACE_ARRAY1[ANY])
- (PyArrayObject* array=NULL)
-{
- npy_intp size[1] = { $1_dim0 };
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
- !require_contiguous(array) || !require_native(array)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
- (PyArrayObject* array=NULL, int i=1)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,1) || !require_contiguous(array)
- || !require_native(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = 1;
- for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
- (PyArrayObject* array=NULL, int i=0)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,1) || !require_contiguous(array)
- || !require_native(array)) SWIG_fail;
- $1 = 1;
- for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
- $2 = (DATA_TYPE*) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
- (PyArrayObject* array=NULL)
-{
- npy_intp size[2] = { $1_dim0, $1_dim1 };
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
- !require_contiguous(array) || !require_native(array)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,2) || !require_contiguous(array)
- || !require_native(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
- !require_native(array)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DATA_TYPE*) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,2) || !require_contiguous(array)
- || !require_native(array) || !require_fortran(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
- !require_native(array) || !require_fortran(array)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DATA_TYPE*) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
- (PyArrayObject* array=NULL)
-{
- npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
- !require_contiguous(array) || !require_native(array)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
- !require_native(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
-}
-
-/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- $1 = PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL)
-{
- npy_intp size[2] = { -1, -1 };
- PyArrayObject* temp_array;
- Py_ssize_t i;
-
- /* length of the list */
- $2 = PyList_Size($input);
-
- /* the arrays */
- array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
- object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
-
- if (array == NULL || object_array == NULL)
- {
- SWIG_fail;
- }
-
- for (i=0; i<$2; i++)
- {
- temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE);
-
- /* the new array must be stored so that it can be destroyed in freearg */
- object_array[i] = temp_array;
-
- if ( !temp_array || !require_dimensions(temp_array, 2) ||
- !require_contiguous(temp_array) ||
- !require_native(temp_array) ||
- !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE)
- ) SWIG_fail;
-
- /* store the size of the first array in the list, then use that for comparison. */
- if (i == 0)
- {
- size[0] = array_size(temp_array,0);
- size[1] = array_size(temp_array,1);
- }
-
- if (!require_size(temp_array, size, 2)) SWIG_fail;
-
- array[i] = (DATA_TYPE*) array_data(temp_array);
- }
-
- $1 = (DATA_TYPE**) array;
- $3 = (DIM_TYPE) size[0];
- $4 = (DIM_TYPE) size[1];
-}
-%typemap(freearg)
- (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- if (array$argnum!=NULL) free(array$argnum);
- if (object_array$argnum!=NULL) free(object_array$argnum);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
- * DATA_TYPE* INPLACE_ARRAY3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,3) || !require_contiguous(array)
- || !require_native(array)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DATA_TYPE*) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
- !require_native(array) || !require_fortran(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
- * DATA_TYPE* INPLACE_FARRAY3)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,3) || !require_contiguous(array)
- || !require_native(array) || !require_fortran(array)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DATA_TYPE*) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
- (PyArrayObject* array=NULL)
-{
- npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3 };
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,4) || !require_size(array, size, 4) ||
- !require_contiguous(array) || !require_native(array)) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3, DIM_TYPE DIM4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
- !require_native(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
- $5 = (DIM_TYPE) array_size(array,3);
-}
-
-/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3, DIM_TYPE DIM4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- $1 = PySequence_Check($input);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL)
-{
- npy_intp size[3] = { -1, -1, -1 };
- PyArrayObject* temp_array;
- Py_ssize_t i;
-
- /* length of the list */
- $2 = PyList_Size($input);
-
- /* the arrays */
- array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
- object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
-
- if (array == NULL || object_array == NULL)
- {
- SWIG_fail;
- }
-
- for (i=0; i<$2; i++)
- {
- temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE);
-
- /* the new array must be stored so that it can be destroyed in freearg */
- object_array[i] = temp_array;
-
- if ( !temp_array || !require_dimensions(temp_array, 3) ||
- !require_contiguous(temp_array) ||
- !require_native(temp_array) ||
- !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE)
- ) SWIG_fail;
-
- /* store the size of the first array in the list, then use that for comparison. */
- if (i == 0)
- {
- size[0] = array_size(temp_array,0);
- size[1] = array_size(temp_array,1);
- size[2] = array_size(temp_array,2);
- }
-
- if (!require_size(temp_array, size, 3)) SWIG_fail;
-
- array[i] = (DATA_TYPE*) array_data(temp_array);
- }
-
- $1 = (DATA_TYPE**) array;
- $3 = (DIM_TYPE) size[0];
- $4 = (DIM_TYPE) size[1];
- $5 = (DIM_TYPE) size[2];
-}
-%typemap(freearg)
- (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- if (array$argnum!=NULL) free(array$argnum);
- if (object_array$argnum!=NULL) free(object_array$argnum);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
- * DATA_TYPE* INPLACE_ARRAY4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,4) || !require_contiguous(array)
- || !require_native(array)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DIM_TYPE) array_size(array,3);
- $5 = (DATA_TYPE*) array_data(array);
-}
-
-/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
- * DIM_TYPE DIM3, DIM_TYPE DIM4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
- !require_native(array) || !require_fortran(array)) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
- $2 = (DIM_TYPE) array_size(array,0);
- $3 = (DIM_TYPE) array_size(array,1);
- $4 = (DIM_TYPE) array_size(array,2);
- $5 = (DIM_TYPE) array_size(array,3);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
- * DATA_TYPE* INPLACE_FARRAY4)
- */
-%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
- fragment="NumPy_Macros")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
-{
- $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
- DATA_TYPECODE);
-}
-%typemap(in,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
- (PyArrayObject* array=NULL)
-{
- array = obj_to_array_no_conversion($input, DATA_TYPECODE);
- if (!array || !require_dimensions(array,4) || !require_contiguous(array)
- || !require_native(array) || !require_fortran(array)) SWIG_fail;
- $1 = (DIM_TYPE) array_size(array,0);
- $2 = (DIM_TYPE) array_size(array,1);
- $3 = (DIM_TYPE) array_size(array,2);
- $4 = (DIM_TYPE) array_size(array,3);
- $5 = (DATA_TYPE*) array_data(array);
-}
-
-/*************************/
-/* Argout Array Typemaps */
-/*************************/
-
-/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
- */
-%typemap(in,numinputs=0,
- fragment="NumPy_Backward_Compatibility,NumPy_Macros")
- (DATA_TYPE ARGOUT_ARRAY1[ANY])
- (PyObject* array = NULL)
-{
- npy_intp dims[1] = { $1_dim0 };
- array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
- if (!array) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(argout)
- (DATA_TYPE ARGOUT_ARRAY1[ANY])
-{
- $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
-}
-
-/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
- */
-%typemap(in,numinputs=1,
- fragment="NumPy_Fragments")
- (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
- (PyObject* array = NULL)
-{
- npy_intp dims[1];
- if (!PyInt_Check($input))
- {
- const char* typestring = pytype_string($input);
- PyErr_Format(PyExc_TypeError,
- "Int dimension expected. '%s' given.",
- typestring);
- SWIG_fail;
- }
- $2 = (DIM_TYPE) PyInt_AsLong($input);
- dims[0] = (npy_intp) $2;
- array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
- if (!array) SWIG_fail;
- $1 = (DATA_TYPE*) array_data(array);
-}
-%typemap(argout)
- (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
-{
- $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
-}
-
-/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
- */
-%typemap(in,numinputs=1,
- fragment="NumPy_Fragments")
- (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
- (PyObject* array = NULL)
-{
- npy_intp dims[1];
- if (!PyInt_Check($input))
- {
- const char* typestring = pytype_string($input);
- PyErr_Format(PyExc_TypeError,
- "Int dimension expected. '%s' given.",
- typestring);
- SWIG_fail;
- }
- $1 = (DIM_TYPE) PyInt_AsLong($input);
- dims[0] = (npy_intp) $1;
- array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
- if (!array) SWIG_fail;
- $2 = (DATA_TYPE*) array_data(array);
-}
-%typemap(argout)
- (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
-{
- $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
-}
-
-/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
- */
-%typemap(in,numinputs=0,
- fragment="NumPy_Backward_Compatibility,NumPy_Macros")
- (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
- (PyObject* array = NULL)
-{
- npy_intp dims[2] = { $1_dim0, $1_dim1 };
- array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
- if (!array) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(argout)
- (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
-{
- $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
-}
-
-/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
- */
-%typemap(in,numinputs=0,
- fragment="NumPy_Backward_Compatibility,NumPy_Macros")
- (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
- (PyObject* array = NULL)
-{
- npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
- array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
- if (!array) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(argout)
- (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
-{
- $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
-}
-
-/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
- */
-%typemap(in,numinputs=0,
- fragment="NumPy_Backward_Compatibility,NumPy_Macros")
- (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
- (PyObject* array = NULL)
-{
- npy_intp dims[4] = { $1_dim0, $1_dim1, $1_dim2, $1_dim3 };
- array = PyArray_SimpleNew(4, dims, DATA_TYPECODE);
- if (!array) SWIG_fail;
- $1 = ($1_ltype) array_data(array);
-}
-%typemap(argout)
- (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
-{
- $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
-}
-
-/*****************************/
-/* Argoutview Array Typemaps */
-/*****************************/
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp)
-{
- $1 = &data_temp;
- $2 = &dim_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
-{
- npy_intp dims[1] = { *$2 };
- PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1)
- (DIM_TYPE dim_temp, DATA_TYPE* data_temp = NULL )
-{
- $1 = &dim_temp;
- $2 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
-{
- npy_intp dims[1] = { *$1 };
- PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
-{
- $1 = &data_temp;
- $2 = &dim1_temp;
- $3 = &dim2_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-{
- npy_intp dims[2] = { *$2, *$3 };
- PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2)
- (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL )
-{
- $1 = &dim1_temp;
- $2 = &dim2_temp;
- $3 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
-{
- npy_intp dims[2] = { *$1, *$2 };
- PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
-{
- $1 = &data_temp;
- $2 = &dim1_temp;
- $3 = &dim2_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
- (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
-{
- npy_intp dims[2] = { *$2, *$3 };
- PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array || !require_fortran(array)) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2)
- (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp = NULL )
-{
- $1 = &dim1_temp;
- $2 = &dim2_temp;
- $3 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
-{
- npy_intp dims[2] = { *$1, *$2 };
- PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array || !require_fortran(array)) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
- DIM_TYPE* DIM3)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
-{
- $1 = &data_temp;
- $2 = &dim1_temp;
- $3 = &dim2_temp;
- $4 = &dim3_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-{
- npy_intp dims[3] = { *$2, *$3, *$4 };
- PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
- DATA_TYPE** ARGOUTVIEW_ARRAY3)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
- (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL)
-{
- $1 = &dim1_temp;
- $2 = &dim2_temp;
- $3 = &dim3_temp;
- $4 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
-{
- npy_intp dims[3] = { *$1, *$2, *$3 };
- PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
- DIM_TYPE* DIM3)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
-{
- $1 = &data_temp;
- $2 = &dim1_temp;
- $3 = &dim2_temp;
- $4 = &dim3_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
- (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
-{
- npy_intp dims[3] = { *$2, *$3, *$4 };
- PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array || !require_fortran(array)) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
- DATA_TYPE** ARGOUTVIEW_FARRAY3)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DATA_TYPE** ARGOUTVIEW_FARRAY3)
- (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL )
-{
- $1 = &dim1_temp;
- $2 = &dim2_temp;
- $3 = &dim3_temp;
- $4 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
-{
- npy_intp dims[3] = { *$1, *$2, *$3 };
- PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array || !require_fortran(array)) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
- DIM_TYPE* DIM3, DIM_TYPE* DIM4)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
-{
- $1 = &data_temp;
- $2 = &dim1_temp;
- $3 = &dim2_temp;
- $4 = &dim3_temp;
- $5 = &dim4_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
-{
- npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
- PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
- DATA_TYPE** ARGOUTVIEW_ARRAY4)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEW_ARRAY4)
- (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL )
-{
- $1 = &dim1_temp;
- $2 = &dim2_temp;
- $3 = &dim3_temp;
- $4 = &dim4_temp;
- $5 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
-{
- npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
- PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
- DIM_TYPE* DIM3, DIM_TYPE* DIM4)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
-{
- $1 = &data_temp;
- $2 = &dim1_temp;
- $3 = &dim2_temp;
- $4 = &dim3_temp;
- $5 = &dim4_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
- (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
-{
- npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
- PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array || !require_fortran(array)) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
- DATA_TYPE** ARGOUTVIEW_FARRAY4)
- */
-%typemap(in,numinputs=0)
- (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEW_FARRAY4)
- (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL )
-{
- $1 = &dim1_temp;
- $2 = &dim2_temp;
- $3 = &dim3_temp;
- $4 = &dim4_temp;
- $5 = &data_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
- (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
-{
- npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
- PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
- PyArrayObject* array = (PyArrayObject*) obj;
-
- if (!array || !require_fortran(array)) SWIG_fail;
- $result = SWIG_Python_AppendOutput($result,obj);
-}
-
-/*************************************/
-/* Managed Argoutview Array Typemaps */
-/*************************************/
-
-/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
- */
-%typemap(in,numinputs=0)
- (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1 )
- (DATA_TYPE* data_temp = NULL , DIM_TYPE dim_temp)
-{
- $1 = &data_temp;
- $2 = &dim_temp;
-}
-%typemap(argout,
- fragment="NumPy_Backward_Compatibility")
- (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 */
-/* *************************************************************** */
-
-/* Concrete instances of the %numpy_typemaps() macro: Each invocation
- * below applies all of the typemaps above to the specified data type.
- */
-%numpy_typemaps(signed char , NPY_BYTE , int)
-%numpy_typemaps(unsigned char , NPY_UBYTE , int)
-%numpy_typemaps(short , NPY_SHORT , int)
-%numpy_typemaps(unsigned short , NPY_USHORT , int)
-%numpy_typemaps(int , NPY_INT , int)
-%numpy_typemaps(unsigned int , NPY_UINT , int)
-%numpy_typemaps(long , NPY_LONG , int)
-%numpy_typemaps(unsigned long , NPY_ULONG , int)
-%numpy_typemaps(long long , NPY_LONGLONG , int)
-%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
-%numpy_typemaps(float , NPY_FLOAT , int)
-%numpy_typemaps(double , NPY_DOUBLE , int)
-
-/* ***************************************************************
- * The follow macro expansion does not work, because C++ bool is 4
- * bytes and NPY_BOOL is 1 byte
- *
- * %numpy_typemaps(bool, NPY_BOOL, int)
- */
-
-/* ***************************************************************
- * On my Mac, I get the following warning for this macro expansion:
- * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
- *
- * %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
- */
-
-/* ***************************************************************
- * Swig complains about a syntax error for the following macro
- * expansions:
- *
- * %numpy_typemaps(complex float, NPY_CFLOAT , int)
- *
- * %numpy_typemaps(complex double, NPY_CDOUBLE, int)
- *
- * %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
- */
-
-#endif /* SWIGPYTHON */
diff --git a/doc/swig/pyfragments.swg b/doc/swig/pyfragments.swg
deleted file mode 100644
index b5decf12c..000000000
--- a/doc/swig/pyfragments.swg
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-*- C -*-*/
-
-/**********************************************************************/
-
-/* For numpy versions prior to 1.0, the names of certain data types
- * are different than in later versions. This fragment provides macro
- * substitutions that allow us to support old and new versions of
- * numpy.
- */
-
-/**********************************************************************/
-
-/* Override the SWIG_AsVal_frag(long) fragment so that it also checks
- * for numpy scalar array types. The code through the %#endif is
- * essentially cut-and-paste from pyprimtype.swg
- */
-
-%fragment(SWIG_AsVal_frag(long), "header",
- fragment="SWIG_CanCastAsInteger",
- fragment="NumPy_Backward_Compatibility")
-{
- SWIGINTERN int
- SWIG_AsVal_dec(long)(PyObject * obj, long * val)
- {
- PyArray_Descr * longDescr = PyArray_DescrNewFromType(NPY_LONG);
- if (PyInt_Check(obj)) {
- if (val) *val = PyInt_AsLong(obj);
- return SWIG_OK;
- } else if (PyLong_Check(obj)) {
- long v = PyLong_AsLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_OK;
- } else {
- PyErr_Clear();
- }
- }
-%#ifdef SWIG_PYTHON_CAST_MODE
- {
- int dispatch = 0;
- long v = PyInt_AsLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_AddCast(SWIG_OK);
- } else {
- PyErr_Clear();
- }
- if (!dispatch) {
- double d;
- int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d));
- if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
- if (val) *val = (long)(d);
- return res;
- }
- }
- }
-%#endif
- if (!PyArray_IsScalar(obj,Integer)) return SWIG_TypeError;
- PyArray_CastScalarToCtype(obj, (void*)val, longDescr);
- return SWIG_OK;
- }
-}
-
-
-/* Override the SWIG_AsVal_frag(unsigned long) fragment so that it
- * also checks for numpy scalar array types. The code through the
- * %#endif is essentially cut-and-paste from pyprimtype.swg
- */
-
-%fragment(SWIG_AsVal_frag(unsigned long),"header",
- fragment="SWIG_CanCastAsInteger",
- fragment="NumPy_Backward_Compatibility")
-{
- SWIGINTERN int
- SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
- {
- PyArray_Descr * ulongDescr = PyArray_DescrNewFromType(NPY_ULONG);
- if (PyInt_Check(obj)) {
- long v = PyInt_AsLong(obj);
- if (v >= 0) {
- if (val) *val = v;
- return SWIG_OK;
- } else {
- return SWIG_OverflowError;
- }
- } else if (PyLong_Check(obj)) {
- unsigned long v = PyLong_AsUnsignedLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_OK;
- } else {
- PyErr_Clear();
- }
- }
-%#ifdef SWIG_PYTHON_CAST_MODE
- {
- int dispatch = 0;
- unsigned long v = PyLong_AsUnsignedLong(obj);
- if (!PyErr_Occurred()) {
- if (val) *val = v;
- return SWIG_AddCast(SWIG_OK);
- } else {
- PyErr_Clear();
- }
- if (!dispatch) {
- double d;
- int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d));
- if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
- if (val) *val = (unsigned long)(d);
- return res;
- }
- }
- }
-%#endif
- if (!PyArray_IsScalar(obj,Integer)) return SWIG_TypeError;
- PyArray_CastScalarToCtype(obj, (void*)val, ulongDescr);
- return SWIG_OK;
- }
-}
diff --git a/doc/swig/test/Array.i b/doc/swig/test/Array.i
deleted file mode 100644
index 6a8605eb6..000000000
--- a/doc/swig/test/Array.i
+++ /dev/null
@@ -1,102 +0,0 @@
-// -*- c++ -*-
-
-%module Array
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "Array1.h"
-#include "Array2.h"
-%}
-
-// Get the NumPy typemaps
-%include "../numpy.i"
-
- // Get the STL typemaps
-%include "stl.i"
-
-// Handle standard exceptions
-%include "exception.i"
-%exception
-{
- try
- {
- $action
- }
- catch (const std::invalid_argument& e)
- {
- SWIG_exception(SWIG_ValueError, e.what());
- }
- catch (const std::out_of_range& e)
- {
- SWIG_exception(SWIG_IndexError, e.what());
- }
-}
-%init %{
- import_array();
-%}
-
-// Global ignores
-%ignore *::operator=;
-%ignore *::operator[];
-
-// Apply the 1D NumPy typemaps
-%apply (int DIM1 , long* INPLACE_ARRAY1)
- {(int length, long* data )};
-%apply (long** ARGOUTVIEW_ARRAY1, int* DIM1 )
- {(long** data , int* length)};
-
-// Apply the 2D NumPy typemaps
-%apply (int DIM1 , int DIM2 , long* INPLACE_ARRAY2)
- {(int nrows, int ncols, long* data )};
-%apply (int* DIM1 , int* DIM2 , long** ARGOUTVIEW_ARRAY2)
- {(int* nrows, int* ncols, long** data )};
-
-// Array1 support
-%include "Array1.h"
-%extend Array1
-{
- void __setitem__(int i, long v)
- {
- self->operator[](i) = v;
- }
-
- long __getitem__(int i)
- {
- return self->operator[](i);
- }
-
- int __len__()
- {
- return self->length();
- }
-
- std::string __str__()
- {
- return self->asString();
- }
-}
-
-// Array2 support
-%include "Array2.h"
-%extend Array2
-{
- void __setitem__(int i, Array1 & v)
- {
- self->operator[](i) = v;
- }
-
- Array1 & __getitem__(int i)
- {
- return self->operator[](i);
- }
-
- int __len__()
- {
- return self->nrows() * self->ncols();
- }
-
- std::string __str__()
- {
- return self->asString();
- }
-}
diff --git a/doc/swig/test/Array1.cxx b/doc/swig/test/Array1.cxx
deleted file mode 100644
index 0c09e02f9..000000000
--- a/doc/swig/test/Array1.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-#include "Array1.h"
-#include <iostream>
-#include <sstream>
-
-// Default/length/array constructor
-Array1::Array1(int length, long* data) :
- _ownData(false), _length(0), _buffer(0)
-{
- resize(length, data);
-}
-
-// Copy constructor
-Array1::Array1(const Array1 & source) :
- _length(source._length)
-{
- allocateMemory();
- *this = source;
-}
-
-// Destructor
-Array1::~Array1()
-{
- deallocateMemory();
-}
-
-// Assignment operator
-Array1 & Array1::operator=(const Array1 & source)
-{
- int len = _length < source._length ? _length : source._length;
- for (int i=0; i < len; ++i)
- {
- (*this)[i] = source[i];
- }
- return *this;
-}
-
-// Equals operator
-bool Array1::operator==(const Array1 & other) const
-{
- if (_length != other._length) return false;
- for (int i=0; i < _length; ++i)
- {
- if ((*this)[i] != other[i]) return false;
- }
- return true;
-}
-
-// Length accessor
-int Array1::length() const
-{
- return _length;
-}
-
-// Resize array
-void Array1::resize(int length, long* data)
-{
- if (length < 0) throw std::invalid_argument("Array1 length less than 0");
- if (length == _length) return;
- deallocateMemory();
- _length = length;
- if (!data)
- {
- allocateMemory();
- }
- else
- {
- _ownData = false;
- _buffer = data;
- }
-}
-
-// Set item accessor
-long & Array1::operator[](int i)
-{
- if (i < 0 || i >= _length) throw std::out_of_range("Array1 index out of range");
- return _buffer[i];
-}
-
-// Get item accessor
-const long & Array1::operator[](int i) const
-{
- if (i < 0 || i >= _length) throw std::out_of_range("Array1 index out of range");
- return _buffer[i];
-}
-
-// String output
-std::string Array1::asString() const
-{
- std::stringstream result;
- result << "[";
- for (int i=0; i < _length; ++i)
- {
- result << " " << _buffer[i];
- if (i < _length-1) result << ",";
- }
- result << " ]";
- return result.str();
-}
-
-// Get view
-void Array1::view(long** data, int* length) const
-{
- *data = _buffer;
- *length = _length;
-}
-
-// Private methods
- void Array1::allocateMemory()
- {
- if (_length == 0)
- {
- _ownData = false;
- _buffer = 0;
- }
- else
- {
- _ownData = true;
- _buffer = new long[_length];
- }
- }
-
- void Array1::deallocateMemory()
- {
- if (_ownData && _length && _buffer)
- {
- delete [] _buffer;
- }
- _ownData = false;
- _length = 0;
- _buffer = 0;
- }
diff --git a/doc/swig/test/Array1.h b/doc/swig/test/Array1.h
deleted file mode 100644
index 754c248fc..000000000
--- a/doc/swig/test/Array1.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef ARRAY1_H
-#define ARRAY1_H
-
-#include <stdexcept>
-#include <string>
-
-class Array1
-{
-public:
-
- // Default/length/array constructor
- Array1(int length = 0, long* data = 0);
-
- // Copy constructor
- Array1(const Array1 & source);
-
- // Destructor
- ~Array1();
-
- // Assignment operator
- Array1 & operator=(const Array1 & source);
-
- // Equals operator
- bool operator==(const Array1 & other) const;
-
- // Length accessor
- int length() const;
-
- // Resize array
- void resize(int length, long* data = 0);
-
- // Set item accessor
- long & operator[](int i);
-
- // Get item accessor
- const long & operator[](int i) const;
-
- // String output
- std::string asString() const;
-
- // Get view
- void view(long** data, int* length) const;
-
-private:
- // Members
- bool _ownData;
- int _length;
- long * _buffer;
-
- // Methods
- void allocateMemory();
- void deallocateMemory();
-};
-
-#endif
diff --git a/doc/swig/test/Array2.cxx b/doc/swig/test/Array2.cxx
deleted file mode 100644
index e3558f786..000000000
--- a/doc/swig/test/Array2.cxx
+++ /dev/null
@@ -1,168 +0,0 @@
-#include "Array2.h"
-#include <sstream>
-
-// Default constructor
-Array2::Array2() :
- _ownData(false), _nrows(0), _ncols(), _buffer(0), _rows(0)
-{ }
-
-// Size/array constructor
-Array2::Array2(int nrows, int ncols, long* data) :
- _ownData(false), _nrows(0), _ncols(), _buffer(0), _rows(0)
-{
- resize(nrows, ncols, data);
-}
-
-// Copy constructor
-Array2::Array2(const Array2 & source) :
- _nrows(source._nrows), _ncols(source._ncols)
-{
- _ownData = true;
- allocateMemory();
- *this = source;
-}
-
-// Destructor
-Array2::~Array2()
-{
- deallocateMemory();
-}
-
-// Assignment operator
-Array2 & Array2::operator=(const Array2 & source)
-{
- int nrows = _nrows < source._nrows ? _nrows : source._nrows;
- int ncols = _ncols < source._ncols ? _ncols : source._ncols;
- for (int i=0; i < nrows; ++i)
- {
- for (int j=0; j < ncols; ++j)
- {
- (*this)[i][j] = source[i][j];
- }
- }
- return *this;
-}
-
-// Equals operator
-bool Array2::operator==(const Array2 & other) const
-{
- if (_nrows != other._nrows) return false;
- if (_ncols != other._ncols) return false;
- for (int i=0; i < _nrows; ++i)
- {
- for (int j=0; j < _ncols; ++j)
- {
- if ((*this)[i][j] != other[i][j]) return false;
- }
- }
- return true;
-}
-
-// Length accessors
-int Array2::nrows() const
-{
- return _nrows;
-}
-
-int Array2::ncols() const
-{
- return _ncols;
-}
-
-// Resize array
-void Array2::resize(int nrows, int ncols, long* data)
-{
- if (nrows < 0) throw std::invalid_argument("Array2 nrows less than 0");
- if (ncols < 0) throw std::invalid_argument("Array2 ncols less than 0");
- if (nrows == _nrows && ncols == _ncols) return;
- deallocateMemory();
- _nrows = nrows;
- _ncols = ncols;
- if (!data)
- {
- allocateMemory();
- }
- else
- {
- _ownData = false;
- _buffer = data;
- allocateRows();
- }
-}
-
-// Set item accessor
-Array1 & Array2::operator[](int i)
-{
- if (i < 0 || i > _nrows) throw std::out_of_range("Array2 row index out of range");
- return _rows[i];
-}
-
-// Get item accessor
-const Array1 & Array2::operator[](int i) const
-{
- if (i < 0 || i > _nrows) throw std::out_of_range("Array2 row index out of range");
- return _rows[i];
-}
-
-// String output
-std::string Array2::asString() const
-{
- std::stringstream result;
- result << "[ ";
- for (int i=0; i < _nrows; ++i)
- {
- if (i > 0) result << " ";
- result << (*this)[i].asString();
- if (i < _nrows-1) result << "," << std::endl;
- }
- result << " ]" << std::endl;
- return result.str();
-}
-
-// Get view
-void Array2::view(int* nrows, int* ncols, long** data) const
-{
- *nrows = _nrows;
- *ncols = _ncols;
- *data = _buffer;
-}
-
-// Private methods
-void Array2::allocateMemory()
-{
- if (_nrows * _ncols == 0)
- {
- _ownData = false;
- _buffer = 0;
- _rows = 0;
- }
- else
- {
- _ownData = true;
- _buffer = new long[_nrows*_ncols];
- allocateRows();
- }
-}
-
-void Array2::allocateRows()
-{
- _rows = new Array1[_nrows];
- for (int i=0; i < _nrows; ++i)
- {
- _rows[i].resize(_ncols, &_buffer[i*_ncols]);
- }
-}
-
-void Array2::deallocateMemory()
-{
- if (_ownData && _nrows*_ncols && _buffer)
- {
- delete [] _rows;
- delete [] _buffer;
- }
- _ownData = false;
- _nrows = 0;
- _ncols = 0;
- _buffer = 0;
- _rows = 0;
-}
diff --git a/doc/swig/test/Array2.h b/doc/swig/test/Array2.h
deleted file mode 100644
index 7f8d4ca65..000000000
--- a/doc/swig/test/Array2.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef ARRAY2_H
-#define ARRAY2_H
-
-#include "Array1.h"
-#include <stdexcept>
-#include <string>
-
-class Array2
-{
-public:
-
- // Default constructor
- Array2();
-
- // Size/array constructor
- Array2(int nrows, int ncols, long* data=0);
-
- // Copy constructor
- Array2(const Array2 & source);
-
- // Destructor
- ~Array2();
-
- // Assignment operator
- Array2 & operator=(const Array2 & source);
-
- // Equals operator
- bool operator==(const Array2 & other) const;
-
- // Length accessors
- int nrows() const;
- int ncols() const;
-
- // Resize array
- void resize(int nrows, int ncols, long* data=0);
-
- // Set item accessor
- Array1 & operator[](int i);
-
- // Get item accessor
- const Array1 & operator[](int i) const;
-
- // String output
- std::string asString() const;
-
- // Get view
- void view(int* nrows, int* ncols, long** data) const;
-
-private:
- // Members
- bool _ownData;
- int _nrows;
- int _ncols;
- long * _buffer;
- Array1 * _rows;
-
- // Methods
- void allocateMemory();
- void allocateRows();
- void deallocateMemory();
-};
-
-#endif
diff --git a/doc/swig/test/Farray.cxx b/doc/swig/test/Farray.cxx
deleted file mode 100644
index 3983c333b..000000000
--- a/doc/swig/test/Farray.cxx
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "Farray.h"
-#include <sstream>
-
-// Size constructor
-Farray::Farray(int nrows, int ncols) :
- _nrows(nrows), _ncols(ncols), _buffer(0)
-{
- allocateMemory();
-}
-
-// Copy constructor
-Farray::Farray(const Farray & source) :
- _nrows(source._nrows), _ncols(source._ncols)
-{
- allocateMemory();
- *this = source;
-}
-
-// Destructor
-Farray::~Farray()
-{
- delete [] _buffer;
-}
-
-// Assignment operator
-Farray & Farray::operator=(const Farray & source)
-{
- int nrows = _nrows < source._nrows ? _nrows : source._nrows;
- int ncols = _ncols < source._ncols ? _ncols : source._ncols;
- for (int i=0; i < nrows; ++i)
- {
- for (int j=0; j < ncols; ++j)
- {
- (*this)(i,j) = source(i,j);
- }
- }
- return *this;
-}
-
-// Equals operator
-bool Farray::operator==(const Farray & other) const
-{
- if (_nrows != other._nrows) return false;
- if (_ncols != other._ncols) return false;
- for (int i=0; i < _nrows; ++i)
- {
- for (int j=0; j < _ncols; ++j)
- {
- if ((*this)(i,j) != other(i,j)) return false;
- }
- }
- return true;
-}
-
-// Length accessors
-int Farray::nrows() const
-{
- return _nrows;
-}
-
-int Farray::ncols() const
-{
- return _ncols;
-}
-
-// Set item accessor
-long & Farray::operator()(int i, int j)
-{
- if (i < 0 || i > _nrows) throw std::out_of_range("Farray row index out of range");
- if (j < 0 || j > _ncols) throw std::out_of_range("Farray col index out of range");
- return _buffer[offset(i,j)];
-}
-
-// Get item accessor
-const long & Farray::operator()(int i, int j) const
-{
- if (i < 0 || i > _nrows) throw std::out_of_range("Farray row index out of range");
- if (j < 0 || j > _ncols) throw std::out_of_range("Farray col index out of range");
- return _buffer[offset(i,j)];
-}
-
-// String output
-std::string Farray::asString() const
-{
- std::stringstream result;
- result << "[ ";
- for (int i=0; i < _nrows; ++i)
- {
- if (i > 0) result << " ";
- result << "[";
- for (int j=0; j < _ncols; ++j)
- {
- result << " " << (*this)(i,j);
- if (j < _ncols-1) result << ",";
- }
- result << " ]";
- if (i < _nrows-1) result << "," << std::endl;
- }
- result << " ]" << std::endl;
- return result.str();
-}
-
-// Get view
-void Farray::view(int* nrows, int* ncols, long** data) const
-{
- *nrows = _nrows;
- *ncols = _ncols;
- *data = _buffer;
-}
-
-// Private methods
-void Farray::allocateMemory()
-{
- if (_nrows <= 0) throw std::invalid_argument("Farray nrows <= 0");
- if (_ncols <= 0) throw std::invalid_argument("Farray ncols <= 0");
- _buffer = new long[_nrows*_ncols];
-}
-
-inline int Farray::offset(int i, int j) const
-{
- return i + j * _nrows;
-}
diff --git a/doc/swig/test/Farray.h b/doc/swig/test/Farray.h
deleted file mode 100644
index 4199a287c..000000000
--- a/doc/swig/test/Farray.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef FARRAY_H
-#define FARRAY_H
-
-#include <stdexcept>
-#include <string>
-
-class Farray
-{
-public:
-
- // Size constructor
- Farray(int nrows, int ncols);
-
- // Copy constructor
- Farray(const Farray & source);
-
- // Destructor
- ~Farray();
-
- // Assignment operator
- Farray & operator=(const Farray & source);
-
- // Equals operator
- bool operator==(const Farray & other) const;
-
- // Length accessors
- int nrows() const;
- int ncols() const;
-
- // Set item accessor
- long & operator()(int i, int j);
-
- // Get item accessor
- const long & operator()(int i, int j) const;
-
- // String output
- std::string asString() const;
-
- // Get view
- void view(int* nrows, int* ncols, long** data) const;
-
-private:
- // Members
- int _nrows;
- int _ncols;
- long * _buffer;
-
- // Default constructor: not implemented
- Farray();
-
- // Methods
- void allocateMemory();
- int offset(int i, int j) const;
-};
-
-#endif
diff --git a/doc/swig/test/Farray.i b/doc/swig/test/Farray.i
deleted file mode 100644
index 25f6cd025..000000000
--- a/doc/swig/test/Farray.i
+++ /dev/null
@@ -1,73 +0,0 @@
-// -*- c++ -*-
-
-%module Farray
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "Farray.h"
-%}
-
-// Get the NumPy typemaps
-%include "../numpy.i"
-
- // Get the STL typemaps
-%include "stl.i"
-
-// Handle standard exceptions
-%include "exception.i"
-%exception
-{
- try
- {
- $action
- }
- catch (const std::invalid_argument& e)
- {
- SWIG_exception(SWIG_ValueError, e.what());
- }
- catch (const std::out_of_range& e)
- {
- SWIG_exception(SWIG_IndexError, e.what());
- }
-}
-%init %{
- import_array();
-%}
-
-// Global ignores
-%ignore *::operator=;
-%ignore *::operator();
-
-// Apply the 2D NumPy typemaps
-%apply (int* DIM1 , int* DIM2 , long** ARGOUTVIEW_FARRAY2)
- {(int* nrows, int* ncols, long** data )};
-
-// Farray support
-%include "Farray.h"
-%extend Farray
-{
- PyObject * __setitem__(PyObject* index, long v)
- {
- int i, j;
- if (!PyArg_ParseTuple(index, "ii:Farray___setitem__",&i,&j)) return NULL;
- self->operator()(i,j) = v;
- return Py_BuildValue("");
- }
-
- PyObject * __getitem__(PyObject * index)
- {
- int i, j;
- if (!PyArg_ParseTuple(index, "ii:Farray___getitem__",&i,&j)) return NULL;
- return SWIG_From_long(self->operator()(i,j));
- }
-
- int __len__()
- {
- return self->nrows() * self->ncols();
- }
-
- std::string __str__()
- {
- return self->asString();
- }
-}
diff --git a/doc/swig/test/Fortran.cxx b/doc/swig/test/Fortran.cxx
deleted file mode 100644
index 475d21ddc..000000000
--- a/doc/swig/test/Fortran.cxx
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-#include "Fortran.h"
-
-#define TEST_FUNCS(TYPE, SNAME) \
-\
-TYPE SNAME ## SecondElement(TYPE * matrix, int rows, int cols) { \
- TYPE result = matrix[1]; \
- return result; \
-} \
-
-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/Fortran.h b/doc/swig/test/Fortran.h
deleted file mode 100644
index c243bb50f..000000000
--- a/doc/swig/test/Fortran.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef FORTRAN_H
-#define FORTRAN_H
-
-#define TEST_FUNC_PROTOS(TYPE, SNAME) \
-\
-TYPE SNAME ## SecondElement( TYPE * matrix, int rows, int cols); \
-
-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/Fortran.i b/doc/swig/test/Fortran.i
deleted file mode 100644
index 131790dd6..000000000
--- a/doc/swig/test/Fortran.i
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- c++ -*-
-%module Fortran
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "Fortran.h"
-%}
-
-// Get the NumPy typemaps
-%include "../numpy.i"
-
-%init %{
- import_array();
-%}
-
-%define %apply_numpy_typemaps(TYPE)
-
-%apply (TYPE* IN_FARRAY2, int DIM1, int DIM2) {(TYPE* matrix, int rows, int cols)};
-
-%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 "Fortran.h"
diff --git a/doc/swig/test/Makefile b/doc/swig/test/Makefile
deleted file mode 100644
index 5360b1ced..000000000
--- a/doc/swig/test/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# SWIG
-INTERFACES = Array.i Farray.i Vector.i Matrix.i Tensor.i Fortran.i
-WRAPPERS = $(INTERFACES:.i=_wrap.cxx)
-PROXIES = $(INTERFACES:.i=.py )
-
-# Default target: build the tests
-.PHONY : all
-all: $(WRAPPERS) Array1.cxx Array1.h Farray.cxx Farray.h Vector.cxx Vector.h \
- Matrix.cxx Matrix.h Tensor.cxx Tensor.h Fortran.h Fortran.cxx
- ./setup.py build_ext -i
-
-# Test target: run the tests
-.PHONY : test
-test: all
- python testVector.py
- python testMatrix.py
- python testTensor.py
- python testArray.py
- python testFarray.py
- python testFortran.py
-
-# Rule: %.i -> %_wrap.cxx
-%_wrap.cxx: %.i %.h ../numpy.i
- swig -c++ -python $<
-%_wrap.cxx: %.i %1.h %2.h ../numpy.i
- swig -c++ -python $<
-
-# Clean target
-.PHONY : clean
-clean:
- $(RM) -r build
- $(RM) *.so
- $(RM) $(WRAPPERS)
- $(RM) $(PROXIES)
diff --git a/doc/swig/test/Matrix.cxx b/doc/swig/test/Matrix.cxx
deleted file mode 100644
index b953d7017..000000000
--- a/doc/swig/test/Matrix.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-#include "Matrix.h"
-
-// The following macro defines a family of functions that work with 2D
-// arrays with the forms
-//
-// TYPE SNAMEDet( TYPE matrix[2][2]);
-// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
-// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
-// void SNAMEScale( TYPE matrix[3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor);
-// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil);
-// void SNAMELUSplit(TYPE in[3][3], TYPE lower[3][3], TYPE upper[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:
-//
-// * 2D input arrays, hard-coded length
-// * 2D input arrays
-// * 2D input arrays, data last
-// * 2D in-place arrays, hard-coded lengths
-// * 2D in-place arrays
-// * 2D in-place arrays, data last
-// * 2D argout arrays, hard-coded length
-//
-#define TEST_FUNCS(TYPE, SNAME) \
-\
-TYPE SNAME ## Det(TYPE matrix[2][2]) { \
- return matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]; \
-} \
-\
-TYPE SNAME ## Max(TYPE * matrix, int rows, int cols) { \
- int i, j, index; \
- TYPE result = matrix[0]; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (matrix[index] > result) result = matrix[index]; \
- } \
- } \
- return result; \
-} \
-\
-TYPE SNAME ## Min(int rows, int cols, TYPE * matrix) { \
- int i, j, index; \
- TYPE result = matrix[0]; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (matrix[index] < result) result = matrix[index]; \
- } \
- } \
- return result; \
-} \
-\
-void SNAME ## Scale(TYPE array[3][3], TYPE val) { \
- for (int i=0; i<3; ++i) \
- for (int j=0; j<3; ++j) \
- array[i][j] *= val; \
-} \
-\
-void SNAME ## Floor(TYPE * array, int rows, int cols, TYPE floor) { \
- int i, j, index; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (array[index] < floor) array[index] = floor; \
- } \
- } \
-} \
-\
-void SNAME ## Ceil(int rows, int cols, TYPE * array, TYPE ceil) { \
- int i, j, index; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (array[index] > ceil) array[index] = ceil; \
- } \
- } \
-} \
-\
-void SNAME ## LUSplit(TYPE matrix[3][3], TYPE lower[3][3], TYPE upper[3][3]) { \
- for (int i=0; i<3; ++i) { \
- for (int j=0; j<3; ++j) { \
- if (i >= j) { \
- lower[i][j] = matrix[i][j]; \
- upper[i][j] = 0; \
- } else { \
- lower[i][j] = 0; \
- upper[i][j] = matrix[i][j]; \
- } \
- } \
- } \
-}
-
-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/Matrix.h b/doc/swig/test/Matrix.h
deleted file mode 100644
index f37836cc4..000000000
--- a/doc/swig/test/Matrix.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef MATRIX_H
-#define MATRIX_H
-
-// The following macro defines the prototypes for a family of
-// functions that work with 2D arrays with the forms
-//
-// TYPE SNAMEDet( TYPE matrix[2][2]);
-// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
-// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
-// void SNAMEScale( TYPE array[3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor);
-// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil );
-// void SNAMELUSplit(TYPE in[3][3], TYPE lower[3][3], TYPE upper[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:
-//
-// * 2D input arrays, hard-coded lengths
-// * 2D input arrays
-// * 2D input arrays, data last
-// * 2D in-place arrays, hard-coded lengths
-// * 2D in-place arrays
-// * 2D in-place arrays, data last
-// * 2D argout arrays, hard-coded length
-//
-#define TEST_FUNC_PROTOS(TYPE, SNAME) \
-\
-TYPE SNAME ## Det( TYPE matrix[2][2]); \
-TYPE SNAME ## Max( TYPE * matrix, int rows, int cols); \
-TYPE SNAME ## Min( int rows, int cols, TYPE * matrix); \
-void SNAME ## Scale( TYPE array[3][3], TYPE val); \
-void SNAME ## Floor( TYPE * array, int rows, int cols, TYPE floor); \
-void SNAME ## Ceil( int rows, int cols, TYPE * array, TYPE ceil ); \
-void SNAME ## LUSplit(TYPE matrix[3][3], TYPE lower[3][3], TYPE upper[3][3]);
-
-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/Matrix.i b/doc/swig/test/Matrix.i
deleted file mode 100644
index e721397a0..000000000
--- a/doc/swig/test/Matrix.i
+++ /dev/null
@@ -1,45 +0,0 @@
-// -*- c++ -*-
-%module Matrix
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "Matrix.h"
-%}
-
-// Get the NumPy typemaps
-%include "../numpy.i"
-
-%init %{
- import_array();
-%}
-
-%define %apply_numpy_typemaps(TYPE)
-
-%apply (TYPE IN_ARRAY2[ANY][ANY]) {(TYPE matrix[ANY][ANY])};
-%apply (TYPE* IN_ARRAY2, int DIM1, int DIM2) {(TYPE* matrix, int rows, int cols)};
-%apply (int DIM1, int DIM2, TYPE* IN_ARRAY2) {(int rows, int cols, TYPE* matrix)};
-
-%apply (TYPE INPLACE_ARRAY2[ANY][ANY]) {(TYPE array[3][3])};
-%apply (TYPE* INPLACE_ARRAY2, int DIM1, int DIM2) {(TYPE* array, int rows, int cols)};
-%apply (int DIM1, int DIM2, TYPE* INPLACE_ARRAY2) {(int rows, int cols, TYPE* array)};
-
-%apply (TYPE ARGOUT_ARRAY2[ANY][ANY]) {(TYPE lower[3][3])};
-%apply (TYPE ARGOUT_ARRAY2[ANY][ANY]) {(TYPE upper[3][3])};
-
-%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 "Matrix.h"
diff --git a/doc/swig/test/SuperTensor.cxx b/doc/swig/test/SuperTensor.cxx
deleted file mode 100644
index 82e8a4bd5..000000000
--- a/doc/swig/test/SuperTensor.cxx
+++ /dev/null
@@ -1,144 +0,0 @@
-#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
deleted file mode 100644
index 29cc3bbbb..000000000
--- a/doc/swig/test/SuperTensor.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#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
deleted file mode 100644
index 7521b8ec4..000000000
--- a/doc/swig/test/SuperTensor.i
+++ /dev/null
@@ -1,50 +0,0 @@
-// -*- 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
deleted file mode 100644
index 4ccefa144..000000000
--- a/doc/swig/test/Tensor.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-#include "Tensor.h"
-
-// The following macro defines a family of functions that work with 3D
-// arrays with the forms
-//
-// TYPE SNAMENorm( TYPE tensor[2][2][2]);
-// 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 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
-// 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:
-//
-// * 3D input arrays, hard-coded length
-// * 3D input arrays
-// * 3D input arrays, data last
-// * 3D in-place arrays, hard-coded lengths
-// * 3D in-place arrays
-// * 3D in-place arrays, data last
-// * 3D argout arrays, hard-coded length
-//
-#define TEST_FUNCS(TYPE, SNAME) \
-\
-TYPE SNAME ## Norm(TYPE tensor[2][2][2]) { \
- double result = 0; \
- for (int k=0; k<2; ++k) \
- for (int j=0; j<2; ++j) \
- for (int i=0; i<2; ++i) \
- result += tensor[k][j][i] * tensor[k][j][i]; \
- return (TYPE)sqrt(result/8); \
-} \
-\
-TYPE SNAME ## Max(TYPE * tensor, int slices, int rows, int cols) { \
- int i, j, k, index; \
- TYPE result = tensor[0]; \
- 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 slices, int rows, int cols, TYPE * tensor) { \
- int i, j, k, index; \
- TYPE result = tensor[0]; \
- 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; \
-} \
-\
-void SNAME ## Scale(TYPE array[3][3][3], TYPE val) { \
- for (int k=0; k<3; ++k) \
- for (int j=0; j<3; ++j) \
- for (int i=0; i<3; ++i) \
- array[k][j][i] *= val; \
-} \
-\
-void SNAME ## Floor(TYPE * array, int slices, int rows, int cols, TYPE floor) { \
- int i, j, k, 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 (array[index] < floor) array[index] = floor; \
- } \
- } \
- } \
-} \
-\
-void SNAME ## Ceil(int slices, int rows, int cols, TYPE * array, TYPE ceil) { \
- int i, j, k, 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 (array[index] > ceil) array[index] = ceil; \
- } \
- } \
- } \
-} \
-\
-void SNAME ## LUSplit(TYPE tensor[2][2][2], TYPE lower[2][2][2], \
- TYPE upper[2][2][2]) { \
- int sum; \
- 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[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; \
- } \
- } \
- } \
- } \
-}
-
-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/Tensor.h b/doc/swig/test/Tensor.h
deleted file mode 100644
index 1f483b328..000000000
--- a/doc/swig/test/Tensor.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef TENSOR_H
-#define TENSOR_H
-
-// The following macro defines the prototypes for a family of
-// functions that work with 3D arrays with the forms
-//
-// TYPE SNAMENorm( TYPE tensor[2][2][2]);
-// 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 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
-// 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:
-//
-// * 3D input arrays, hard-coded lengths
-// * 3D input arrays
-// * 3D input arrays, data last
-// * 3D in-place arrays, hard-coded lengths
-// * 3D in-place arrays
-// * 3D in-place arrays, data last
-// * 3D argout arrays, hard-coded length
-//
-#define TEST_FUNC_PROTOS(TYPE, SNAME) \
-\
-TYPE SNAME ## Norm( TYPE tensor[2][2][2]); \
-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 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 )
-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/Tensor.i b/doc/swig/test/Tensor.i
deleted file mode 100644
index 5bf9da7e2..000000000
--- a/doc/swig/test/Tensor.i
+++ /dev/null
@@ -1,49 +0,0 @@
-// -*- c++ -*-
-%module Tensor
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "Tensor.h"
-%}
-
-// Get the NumPy typemaps
-%include "../numpy.i"
-
-%init %{
- import_array();
-%}
-
-%define %apply_numpy_typemaps(TYPE)
-
-%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 slices, int rows, int cols)};
-%apply (int DIM1, int DIM2, int DIM3, TYPE* IN_ARRAY3)
- {(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 slices, int rows, int cols)};
-%apply (int DIM1, int DIM2, int DIM3, TYPE* INPLACE_ARRAY3)
- {(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])};
-
-%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 "Tensor.h"
diff --git a/doc/swig/test/Vector.cxx b/doc/swig/test/Vector.cxx
deleted file mode 100644
index 2c90404da..000000000
--- a/doc/swig/test/Vector.cxx
+++ /dev/null
@@ -1,100 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-#include "Vector.h"
-
-// The following macro defines a family of functions that work with 1D
-// arrays with the forms
-//
-// TYPE SNAMELength( TYPE vector[3]);
-// TYPE SNAMEProd( TYPE * series, int size);
-// TYPE SNAMESum( int size, TYPE * series);
-// void SNAMEReverse(TYPE array[3]);
-// void SNAMEOnes( TYPE * array, int size);
-// void SNAMEZeros( int size, TYPE * array);
-// void SNAMEEOSplit(TYPE vector[3], TYPE even[3], odd[3]);
-// void SNAMETwos( TYPE * twoVec, int size);
-// void SNAMEThrees( int size, TYPE * threeVec);
-//
-// 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:
-//
-// * 1D input arrays, hard-coded length
-// * 1D input arrays
-// * 1D input arrays, data last
-// * 1D in-place arrays, hard-coded length
-// * 1D in-place arrays
-// * 1D in-place arrays, data last
-// * 1D argout arrays, hard-coded length
-// * 1D argout arrays
-// * 1D argout arrays, data last
-//
-#define TEST_FUNCS(TYPE, SNAME) \
-\
-TYPE SNAME ## Length(TYPE vector[3]) { \
- double result = 0; \
- for (int i=0; i<3; ++i) result += vector[i]*vector[i]; \
- return (TYPE)sqrt(result); \
-} \
-\
-TYPE SNAME ## Prod(TYPE * series, int size) { \
- TYPE result = 1; \
- for (int i=0; i<size; ++i) result *= series[i]; \
- return result; \
-} \
-\
-TYPE SNAME ## Sum(int size, TYPE * series) { \
- TYPE result = 0; \
- for (int i=0; i<size; ++i) result += series[i]; \
- return result; \
-} \
-\
-void SNAME ## Reverse(TYPE array[3]) { \
- TYPE temp = array[0]; \
- array[0] = array[2]; \
- array[2] = temp; \
-} \
-\
-void SNAME ## Ones(TYPE * array, int size) { \
- for (int i=0; i<size; ++i) array[i] = 1; \
-} \
-\
-void SNAME ## Zeros(int size, TYPE * array) { \
- for (int i=0; i<size; ++i) array[i] = 0; \
-} \
-\
-void SNAME ## EOSplit(TYPE vector[3], TYPE even[3], TYPE odd[3]) { \
- for (int i=0; i<3; ++i) { \
- if (i % 2 == 0) { \
- even[i] = vector[i]; \
- odd[ i] = 0; \
- } else { \
- even[i] = 0; \
- odd[ i] = vector[i]; \
- } \
- } \
-} \
-\
-void SNAME ## Twos(TYPE* twoVec, int size) { \
- for (int i=0; i<size; ++i) twoVec[i] = 2; \
-} \
-\
-void SNAME ## Threes(int size, TYPE* threeVec) { \
- for (int i=0; i<size; ++i) threeVec[i] = 3; \
-}
-
-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/Vector.h b/doc/swig/test/Vector.h
deleted file mode 100644
index 01da361c6..000000000
--- a/doc/swig/test/Vector.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef VECTOR_H
-#define VECTOR_H
-
-// The following macro defines the prototypes for a family of
-// functions that work with 1D arrays with the forms
-//
-// TYPE SNAMELength( TYPE vector[3]);
-// TYPE SNAMEProd( TYPE * series, int size);
-// TYPE SNAMESum( int size, TYPE * series);
-// void SNAMEReverse(TYPE array[3]);
-// void SNAMEOnes( TYPE * array, int size);
-// void SNAMEZeros( int size, TYPE * array);
-// void SNAMEEOSplit(TYPE vector[3], TYPE even[3], TYPE odd[3]);
-// void SNAMETwos( TYPE * twoVec, int size);
-// void SNAMEThrees( int size, TYPE * threeVec);
-//
-// 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:
-//
-// * 1D input arrays, hard-coded length
-// * 1D input arrays
-// * 1D input arrays, data last
-// * 1D in-place arrays, hard-coded length
-// * 1D in-place arrays
-// * 1D in-place arrays, data last
-// * 1D argout arrays, hard-coded length
-// * 1D argout arrays
-// * 1D argout arrays, data last
-//
-#define TEST_FUNC_PROTOS(TYPE, SNAME) \
-\
-TYPE SNAME ## Length( TYPE vector[3]); \
-TYPE SNAME ## Prod( TYPE * series, int size); \
-TYPE SNAME ## Sum( int size, TYPE * series); \
-void SNAME ## Reverse(TYPE array[3]); \
-void SNAME ## Ones( TYPE * array, int size); \
-void SNAME ## Zeros( int size, TYPE * array); \
-void SNAME ## EOSplit(TYPE vector[3], TYPE even[3], TYPE odd[3]); \
-void SNAME ## Twos( TYPE * twoVec, int size); \
-void SNAME ## Threes( int size, TYPE * threeVec); \
-
-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/Vector.i b/doc/swig/test/Vector.i
deleted file mode 100644
index e86f21c37..000000000
--- a/doc/swig/test/Vector.i
+++ /dev/null
@@ -1,47 +0,0 @@
-// -*- c++ -*-
-%module Vector
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "Vector.h"
-%}
-
-// Get the NumPy typemaps
-%include "../numpy.i"
-
-%init %{
- import_array();
-%}
-
-%define %apply_numpy_typemaps(TYPE)
-
-%apply (TYPE IN_ARRAY1[ANY]) {(TYPE vector[3])};
-%apply (TYPE* IN_ARRAY1, int DIM1) {(TYPE* series, int size)};
-%apply (int DIM1, TYPE* IN_ARRAY1) {(int size, TYPE* series)};
-
-%apply (TYPE INPLACE_ARRAY1[ANY]) {(TYPE array[3])};
-%apply (TYPE* INPLACE_ARRAY1, int DIM1) {(TYPE* array, int size)};
-%apply (int DIM1, TYPE* INPLACE_ARRAY1) {(int size, TYPE* array)};
-
-%apply (TYPE ARGOUT_ARRAY1[ANY]) {(TYPE even[3])};
-%apply (TYPE ARGOUT_ARRAY1[ANY]) {(TYPE odd[ 3])};
-%apply (TYPE* ARGOUT_ARRAY1, int DIM1) {(TYPE* twoVec, int size)};
-%apply (int DIM1, TYPE* ARGOUT_ARRAY1) {(int size, TYPE* threeVec)};
-
-%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 "Vector.h"
diff --git a/doc/swig/test/setup.py b/doc/swig/test/setup.py
deleted file mode 100755
index e39114f91..000000000
--- a/doc/swig/test/setup.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, print_function
-
-# System imports
-from distutils.core import *
-from distutils import sysconfig
-
-# Third-party modules - we depend on numpy for everything
-import numpy
-
-# Obtain the numpy include directory.
-numpy_include = numpy.get_include()
-
-# Array extension module
-_Array = Extension("_Array",
- ["Array_wrap.cxx",
- "Array1.cxx",
- "Array2.cxx"],
- include_dirs = [numpy_include],
- )
-
-# Farray extension module
-_Farray = Extension("_Farray",
- ["Farray_wrap.cxx",
- "Farray.cxx"],
- include_dirs = [numpy_include],
- )
-
-# _Vector extension module
-_Vector = Extension("_Vector",
- ["Vector_wrap.cxx",
- "Vector.cxx"],
- include_dirs = [numpy_include],
- )
-
-# _Matrix extension module
-_Matrix = Extension("_Matrix",
- ["Matrix_wrap.cxx",
- "Matrix.cxx"],
- include_dirs = [numpy_include],
- )
-
-# _Tensor extension module
-_Tensor = Extension("_Tensor",
- ["Tensor_wrap.cxx",
- "Tensor.cxx"],
- include_dirs = [numpy_include],
- )
-
-_Fortran = Extension("_Fortran",
- ["Fortran_wrap.cxx",
- "Fortran.cxx"],
- include_dirs = [numpy_include],
- )
-
-# NumyTypemapTests setup
-setup(name = "NumpyTypemapTests",
- description = "Functions that work on arrays",
- author = "Bill Spotz",
- py_modules = ["Array", "Farray", "Vector", "Matrix", "Tensor",
- "Fortran"],
- ext_modules = [_Array, _Farray, _Vector, _Matrix, _Tensor,
- _Fortran]
- )
diff --git a/doc/swig/test/testArray.py b/doc/swig/test/testArray.py
deleted file mode 100755
index d986de3b3..000000000
--- a/doc/swig/test/testArray.py
+++ /dev/null
@@ -1,284 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, absolute_import, print_function
-
-# System imports
-from distutils.util import get_platform
-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 Array
-
-######################################################################
-
-class Array1TestCase(unittest.TestCase):
-
- def setUp(self):
- self.length = 5
- self.array1 = Array.Array1(self.length)
-
- def testConstructor0(self):
- "Test Array1 default constructor"
- a = Array.Array1()
- self.failUnless(isinstance(a, Array.Array1))
- self.failUnless(len(a) == 0)
-
- def testConstructor1(self):
- "Test Array1 length constructor"
- self.failUnless(isinstance(self.array1, Array.Array1))
-
- def testConstructor2(self):
- "Test Array1 array constructor"
- na = np.arange(self.length)
- aa = Array.Array1(na)
- self.failUnless(isinstance(aa, Array.Array1))
-
- def testConstructor3(self):
- "Test Array1 copy constructor"
- for i in range(self.array1.length()): self.array1[i] = i
- arrayCopy = Array.Array1(self.array1)
- self.failUnless(arrayCopy == self.array1)
-
- def testConstructorBad(self):
- "Test Array1 length constructor, negative"
- self.assertRaises(ValueError, Array.Array1, -4)
-
- def testLength(self):
- "Test Array1 length method"
- self.failUnless(self.array1.length() == self.length)
-
- def testLen(self):
- "Test Array1 __len__ method"
- self.failUnless(len(self.array1) == self.length)
-
- def testResize0(self):
- "Test Array1 resize method, length"
- newLen = 2 * self.length
- self.array1.resize(newLen)
- self.failUnless(len(self.array1) == newLen)
-
- def testResize1(self):
- "Test Array1 resize method, array"
- a = np.zeros((2*self.length,), dtype='l')
- self.array1.resize(a)
- self.failUnless(len(self.array1) == a.size)
-
- def testResizeBad(self):
- "Test Array1 resize method, negative length"
- self.assertRaises(ValueError, self.array1.resize, -5)
-
- def testSetGet(self):
- "Test Array1 __setitem__, __getitem__ methods"
- n = self.length
- for i in range(n):
- self.array1[i] = i*i
- for i in range(n):
- self.failUnless(self.array1[i] == i*i)
-
- def testSetBad1(self):
- "Test Array1 __setitem__ method, negative index"
- self.assertRaises(IndexError, self.array1.__setitem__, -1, 0)
-
- def testSetBad2(self):
- "Test Array1 __setitem__ method, out-of-range index"
- self.assertRaises(IndexError, self.array1.__setitem__, self.length+1, 0)
-
- def testGetBad1(self):
- "Test Array1 __getitem__ method, negative index"
- self.assertRaises(IndexError, self.array1.__getitem__, -1)
-
- def testGetBad2(self):
- "Test Array1 __getitem__ method, out-of-range index"
- self.assertRaises(IndexError, self.array1.__getitem__, self.length+1)
-
- def testAsString(self):
- "Test Array1 asString method"
- for i in range(self.array1.length()): self.array1[i] = i+1
- self.failUnless(self.array1.asString() == "[ 1, 2, 3, 4, 5 ]")
-
- def testStr(self):
- "Test Array1 __str__ method"
- for i in range(self.array1.length()): self.array1[i] = i-2
- self.failUnless(str(self.array1) == "[ -2, -1, 0, 1, 2 ]")
-
- def testView(self):
- "Test Array1 view method"
- for i in range(self.array1.length()): self.array1[i] = i+1
- a = self.array1.view()
- self.failUnless(isinstance(a, np.ndarray))
- self.failUnless(len(a) == self.length)
- self.failUnless((a == [1, 2, 3, 4, 5]).all())
-
-######################################################################
-
-class Array2TestCase(unittest.TestCase):
-
- def setUp(self):
- self.nrows = 5
- self.ncols = 4
- self.array2 = Array.Array2(self.nrows, self.ncols)
-
- def testConstructor0(self):
- "Test Array2 default constructor"
- a = Array.Array2()
- self.failUnless(isinstance(a, Array.Array2))
- self.failUnless(len(a) == 0)
-
- def testConstructor1(self):
- "Test Array2 nrows, ncols constructor"
- self.failUnless(isinstance(self.array2, Array.Array2))
-
- def testConstructor2(self):
- "Test Array2 array constructor"
- na = np.zeros((3, 4), dtype="l")
- aa = Array.Array2(na)
- self.failUnless(isinstance(aa, Array.Array2))
-
- def testConstructor3(self):
- "Test Array2 copy constructor"
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array2[i][j] = i * j
- arrayCopy = Array.Array2(self.array2)
- self.failUnless(arrayCopy == self.array2)
-
- def testConstructorBad1(self):
- "Test Array2 nrows, ncols constructor, negative nrows"
- self.assertRaises(ValueError, Array.Array2, -4, 4)
-
- def testConstructorBad2(self):
- "Test Array2 nrows, ncols constructor, negative ncols"
- self.assertRaises(ValueError, Array.Array2, 4, -4)
-
- def testNrows(self):
- "Test Array2 nrows method"
- self.failUnless(self.array2.nrows() == self.nrows)
-
- def testNcols(self):
- "Test Array2 ncols method"
- self.failUnless(self.array2.ncols() == self.ncols)
-
- def testLen(self):
- "Test Array2 __len__ method"
- self.failUnless(len(self.array2) == self.nrows*self.ncols)
-
- def testResize0(self):
- "Test Array2 resize method, size"
- newRows = 2 * self.nrows
- newCols = 2 * self.ncols
- 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) == a.size)
-
- def testResizeBad1(self):
- "Test Array2 resize method, negative nrows"
- self.assertRaises(ValueError, self.array2.resize, -5, 5)
-
- def testResizeBad2(self):
- "Test Array2 resize method, negative ncols"
- self.assertRaises(ValueError, self.array2.resize, 5, -5)
-
- def testSetGet1(self):
- "Test Array2 __setitem__, __getitem__ methods"
- m = self.nrows
- n = self.ncols
- array1 = [ ]
- a = np.arange(n, dtype="l")
- for i in range(m):
- array1.append(Array.Array1(i*a))
- for i in range(m):
- self.array2[i] = array1[i]
- for i in range(m):
- self.failUnless(self.array2[i] == array1[i])
-
- def testSetGet2(self):
- "Test Array2 chained __setitem__, __getitem__ methods"
- m = self.nrows
- n = self.ncols
- for i in range(m):
- for j in range(n):
- self.array2[i][j] = i*j
- for i in range(m):
- for j in range(n):
- self.failUnless(self.array2[i][j] == i*j)
-
- def testSetBad1(self):
- "Test Array2 __setitem__ method, negative index"
- a = Array.Array1(self.ncols)
- self.assertRaises(IndexError, self.array2.__setitem__, -1, a)
-
- def testSetBad2(self):
- "Test Array2 __setitem__ method, out-of-range index"
- a = Array.Array1(self.ncols)
- self.assertRaises(IndexError, self.array2.__setitem__, self.nrows+1, a)
-
- def testGetBad1(self):
- "Test Array2 __getitem__ method, negative index"
- self.assertRaises(IndexError, self.array2.__getitem__, -1)
-
- def testGetBad2(self):
- "Test Array2 __getitem__ method, out-of-range index"
- self.assertRaises(IndexError, self.array2.__getitem__, self.nrows+1)
-
- def testAsString(self):
- "Test Array2 asString method"
- result = """\
-[ [ 0, 1, 2, 3 ],
- [ 1, 2, 3, 4 ],
- [ 2, 3, 4, 5 ],
- [ 3, 4, 5, 6 ],
- [ 4, 5, 6, 7 ] ]
-"""
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array2[i][j] = i+j
- self.failUnless(self.array2.asString() == result)
-
- def testStr(self):
- "Test Array2 __str__ method"
- result = """\
-[ [ 0, -1, -2, -3 ],
- [ 1, 0, -1, -2 ],
- [ 2, 1, 0, -1 ],
- [ 3, 2, 1, 0 ],
- [ 4, 3, 2, 1 ] ]
-"""
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array2[i][j] = i-j
- self.failUnless(str(self.array2) == result)
-
- def testView(self):
- "Test Array2 view method"
- a = self.array2.view()
- self.failUnless(isinstance(a, np.ndarray))
- self.failUnless(len(a) == self.nrows)
-
-######################################################################
-
-if __name__ == "__main__":
-
- # Build the test suite
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Array1TestCase))
- suite.addTest(unittest.makeSuite(Array2TestCase))
-
- # Execute the test suite
- print("Testing Classes of Module Array")
- print("NumPy version", np.__version__)
- print()
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- sys.exit(len(result.errors) + len(result.failures))
diff --git a/doc/swig/test/testFarray.py b/doc/swig/test/testFarray.py
deleted file mode 100755
index 15683b70b..000000000
--- a/doc/swig/test/testFarray.py
+++ /dev/null
@@ -1,159 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, absolute_import, print_function
-
-# System imports
-from distutils.util import get_platform
-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
-
-# Add the distutils-generated build directory to the python search path and then
-# import the extension module
-libDir = "lib.%s-%s" % (get_platform(), sys.version[:3])
-sys.path.insert(0, os.path.join("build", libDir))
-import Farray
-
-######################################################################
-
-class FarrayTestCase(unittest.TestCase):
-
- def setUp(self):
- self.nrows = 5
- self.ncols = 4
- self.array = Farray.Farray(self.nrows, self.ncols)
-
- def testConstructor1(self):
- "Test Farray size constructor"
- self.failUnless(isinstance(self.array, Farray.Farray))
-
- def testConstructor2(self):
- "Test Farray copy constructor"
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array[i, j] = i + j
- arrayCopy = Farray.Farray(self.array)
- self.failUnless(arrayCopy == self.array)
-
- def testConstructorBad1(self):
- "Test Farray size constructor, negative nrows"
- self.assertRaises(ValueError, Farray.Farray, -4, 4)
-
- def testConstructorBad2(self):
- "Test Farray size constructor, negative ncols"
- self.assertRaises(ValueError, Farray.Farray, 4, -4)
-
- def testNrows(self):
- "Test Farray nrows method"
- self.failUnless(self.array.nrows() == self.nrows)
-
- def testNcols(self):
- "Test Farray ncols method"
- self.failUnless(self.array.ncols() == self.ncols)
-
- def testLen(self):
- "Test Farray __len__ method"
- self.failUnless(len(self.array) == self.nrows*self.ncols)
-
- def testSetGet(self):
- "Test Farray __setitem__, __getitem__ methods"
- m = self.nrows
- n = self.ncols
- for i in range(m):
- for j in range(n):
- self.array[i, j] = i*j
- for i in range(m):
- for j in range(n):
- self.failUnless(self.array[i, j] == i*j)
-
- def testSetBad1(self):
- "Test Farray __setitem__ method, negative row"
- self.assertRaises(IndexError, self.array.__setitem__, (-1, 3), 0)
-
- def testSetBad2(self):
- "Test Farray __setitem__ method, negative col"
- self.assertRaises(IndexError, self.array.__setitem__, (1, -3), 0)
-
- def testSetBad3(self):
- "Test Farray __setitem__ method, out-of-range row"
- self.assertRaises(IndexError, self.array.__setitem__, (self.nrows+1, 0), 0)
-
- def testSetBad4(self):
- "Test Farray __setitem__ method, out-of-range col"
- self.assertRaises(IndexError, self.array.__setitem__, (0, self.ncols+1), 0)
-
- def testGetBad1(self):
- "Test Farray __getitem__ method, negative row"
- self.assertRaises(IndexError, self.array.__getitem__, (-1, 3))
-
- def testGetBad2(self):
- "Test Farray __getitem__ method, negative col"
- self.assertRaises(IndexError, self.array.__getitem__, (1, -3))
-
- def testGetBad3(self):
- "Test Farray __getitem__ method, out-of-range row"
- self.assertRaises(IndexError, self.array.__getitem__, (self.nrows+1, 0))
-
- def testGetBad4(self):
- "Test Farray __getitem__ method, out-of-range col"
- self.assertRaises(IndexError, self.array.__getitem__, (0, self.ncols+1))
-
- def testAsString(self):
- "Test Farray asString method"
- result = """\
-[ [ 0, 1, 2, 3 ],
- [ 1, 2, 3, 4 ],
- [ 2, 3, 4, 5 ],
- [ 3, 4, 5, 6 ],
- [ 4, 5, 6, 7 ] ]
-"""
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array[i, j] = i+j
- self.failUnless(self.array.asString() == result)
-
- def testStr(self):
- "Test Farray __str__ method"
- result = """\
-[ [ 0, -1, -2, -3 ],
- [ 1, 0, -1, -2 ],
- [ 2, 1, 0, -1 ],
- [ 3, 2, 1, 0 ],
- [ 4, 3, 2, 1 ] ]
-"""
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array[i, j] = i-j
- self.failUnless(str(self.array) == result)
-
- def testView(self):
- "Test Farray view method"
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.array[i, j] = i+j
- a = self.array.view()
- self.failUnless(isinstance(a, np.ndarray))
- self.failUnless(a.flags.f_contiguous)
- for i in range(self.nrows):
- for j in range(self.ncols):
- self.failUnless(a[i, j] == i+j)
-
-######################################################################
-
-if __name__ == "__main__":
-
- # Build the test suite
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(FarrayTestCase))
-
- # Execute the test suite
- print("Testing Classes of Module Farray")
- print("NumPy version", np.__version__)
- print()
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- sys.exit(len(result.errors) + len(result.failures))
diff --git a/doc/swig/test/testFortran.py b/doc/swig/test/testFortran.py
deleted file mode 100644
index a42af950e..000000000
--- a/doc/swig/test/testFortran.py
+++ /dev/null
@@ -1,173 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, absolute_import, print_function
-
-# System imports
-from distutils.util import get_platform
-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 Fortran
-
-######################################################################
-
-class FortranTestCase(unittest.TestCase):
-
- def __init__(self, methodName="runTests"):
- unittest.TestCase.__init__(self, methodName)
- self.typeStr = "double"
- self.typeCode = "d"
-
- # 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 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),
- self.typeCode)
- self.assertEquals(second(matrix), 3)
-
- def testSecondElementObject(self):
- "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)
- self.assertEquals(second(matrix), 3)
-
-######################################################################
-
-class scharTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "schar"
- self.typeCode = "b"
-
-######################################################################
-
-class ucharTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "uchar"
- self.typeCode = "B"
-
-######################################################################
-
-class shortTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "short"
- self.typeCode = "h"
-
-######################################################################
-
-class ushortTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "ushort"
- self.typeCode = "H"
-
-######################################################################
-
-class intTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "int"
- self.typeCode = "i"
-
-######################################################################
-
-class uintTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "uint"
- self.typeCode = "I"
-
-######################################################################
-
-class longTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "long"
- self.typeCode = "l"
-
-######################################################################
-
-class ulongTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "ulong"
- self.typeCode = "L"
-
-######################################################################
-
-class longLongTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "longLong"
- self.typeCode = "q"
-
-######################################################################
-
-class ulongLongTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "ulongLong"
- self.typeCode = "Q"
-
-######################################################################
-
-class floatTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__init__(self, methodName)
- self.typeStr = "float"
- self.typeCode = "f"
-
-######################################################################
-
-class doubleTestCase(FortranTestCase):
- def __init__(self, methodName="runTest"):
- FortranTestCase.__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 2D Functions of Module Matrix")
- print("NumPy version", np.__version__)
- print()
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- sys.exit(len(result.errors) + len(result.failures))
diff --git a/doc/swig/test/testMatrix.py b/doc/swig/test/testMatrix.py
deleted file mode 100755
index af234e0e9..000000000
--- a/doc/swig/test/testMatrix.py
+++ /dev/null
@@ -1,362 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, absolute_import, print_function
-
-# System imports
-from distutils.util import get_platform
-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 Matrix
-
-######################################################################
-
-class MatrixTestCase(unittest.TestCase):
-
- def __init__(self, methodName="runTests"):
- unittest.TestCase.__init__(self, methodName)
- self.typeStr = "double"
- self.typeCode = "d"
-
- # Test (type IN_ARRAY2[ANY][ANY]) typemap
- def testDet(self):
- "Test det function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- det = Matrix.__dict__[self.typeStr + "Det"]
- matrix = [[8, 7], [6, 9]]
- self.assertEquals(det(matrix), 30)
-
- # Test (type IN_ARRAY2[ANY][ANY]) typemap
- def testDetBadList(self):
- "Test det function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- det = Matrix.__dict__[self.typeStr + "Det"]
- matrix = [[8, 7], ["e", "pi"]]
- self.assertRaises(BadListError, det, matrix)
-
- # Test (type IN_ARRAY2[ANY][ANY]) typemap
- def testDetWrongDim(self):
- "Test det function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- det = Matrix.__dict__[self.typeStr + "Det"]
- matrix = [8, 7]
- self.assertRaises(TypeError, det, matrix)
-
- # Test (type IN_ARRAY2[ANY][ANY]) typemap
- def testDetWrongSize(self):
- "Test det function with wrong size"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- det = Matrix.__dict__[self.typeStr + "Det"]
- matrix = [[8, 7, 6], [5, 4, 3], [2, 1, 0]]
- self.assertRaises(TypeError, det, matrix)
-
- # Test (type IN_ARRAY2[ANY][ANY]) typemap
- def testDetNonContainer(self):
- "Test det function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- det = Matrix.__dict__[self.typeStr + "Det"]
- self.assertRaises(TypeError, det, None)
-
- # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
- def testMax(self):
- "Test max function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Matrix.__dict__[self.typeStr + "Max"]
- matrix = [[6, 5, 4], [3, 2, 1]]
- self.assertEquals(max(matrix), 6)
-
- # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
- def testMaxBadList(self):
- "Test max function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Matrix.__dict__[self.typeStr + "Max"]
- matrix = [[6, "five", 4], ["three", 2, "one"]]
- self.assertRaises(BadListError, max, matrix)
-
- # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
- def testMaxNonContainer(self):
- "Test max function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Matrix.__dict__[self.typeStr + "Max"]
- self.assertRaises(TypeError, max, None)
-
- # Test (type* IN_ARRAY2, int DIM1, int DIM2) typemap
- def testMaxWrongDim(self):
- "Test max function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Matrix.__dict__[self.typeStr + "Max"]
- self.assertRaises(TypeError, max, [0, 1, 2, 3])
-
- # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
- def testMin(self):
- "Test min function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Matrix.__dict__[self.typeStr + "Min"]
- matrix = [[9, 8], [7, 6], [5, 4]]
- self.assertEquals(min(matrix), 4)
-
- # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
- def testMinBadList(self):
- "Test min function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Matrix.__dict__[self.typeStr + "Min"]
- matrix = [["nine", "eight"], ["seven", "six"]]
- self.assertRaises(BadListError, min, matrix)
-
- # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
- def testMinWrongDim(self):
- "Test min function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Matrix.__dict__[self.typeStr + "Min"]
- self.assertRaises(TypeError, min, [1, 3, 5, 7, 9])
-
- # Test (int DIM1, int DIM2, type* IN_ARRAY2) typemap
- def testMinNonContainer(self):
- "Test min function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Matrix.__dict__[self.typeStr + "Min"]
- self.assertRaises(TypeError, min, False)
-
- # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap
- def testScale(self):
- "Test scale function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Matrix.__dict__[self.typeStr + "Scale"]
- matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], self.typeCode)
- scale(matrix, 4)
- self.assertEquals((matrix == [[4, 8, 12], [8, 4, 8], [12, 8, 4]]).all(), True)
-
- # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap
- def testScaleWrongDim(self):
- "Test scale function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Matrix.__dict__[self.typeStr + "Scale"]
- matrix = np.array([1, 2, 2, 1], self.typeCode)
- self.assertRaises(TypeError, scale, matrix)
-
- # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap
- def testScaleWrongSize(self):
- "Test scale function with wrong size"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Matrix.__dict__[self.typeStr + "Scale"]
- matrix = np.array([[1, 2], [2, 1]], self.typeCode)
- self.assertRaises(TypeError, scale, matrix)
-
- # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap
- def testScaleWrongType(self):
- "Test scale function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Matrix.__dict__[self.typeStr + "Scale"]
- matrix = np.array([[1, 2, 3], [2, 1, 2], [3, 2, 1]], 'c')
- self.assertRaises(TypeError, scale, matrix)
-
- # Test (type INPLACE_ARRAY2[ANY][ANY]) typemap
- def testScaleNonArray(self):
- "Test scale function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Matrix.__dict__[self.typeStr + "Scale"]
- matrix = [[1, 2, 3], [2, 1, 2], [3, 2, 1]]
- self.assertRaises(TypeError, scale, matrix)
-
- # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap
- def testFloor(self):
- "Test floor function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Matrix.__dict__[self.typeStr + "Floor"]
- matrix = np.array([[6, 7], [8, 9]], self.typeCode)
- floor(matrix, 7)
- np.testing.assert_array_equal(matrix, np.array([[7, 7], [8, 9]]))
-
- # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap
- def testFloorWrongDim(self):
- "Test floor function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Matrix.__dict__[self.typeStr + "Floor"]
- matrix = np.array([6, 7, 8, 9], self.typeCode)
- self.assertRaises(TypeError, floor, matrix)
-
- # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap
- def testFloorWrongType(self):
- "Test floor function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Matrix.__dict__[self.typeStr + "Floor"]
- matrix = np.array([[6, 7], [8, 9]], 'c')
- self.assertRaises(TypeError, floor, matrix)
-
- # Test (type* INPLACE_ARRAY2, int DIM1, int DIM2) typemap
- def testFloorNonArray(self):
- "Test floor function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Matrix.__dict__[self.typeStr + "Floor"]
- matrix = [[6, 7], [8, 9]]
- self.assertRaises(TypeError, floor, matrix)
-
- # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap
- def testCeil(self):
- "Test ceil function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Matrix.__dict__[self.typeStr + "Ceil"]
- matrix = np.array([[1, 2], [3, 4]], self.typeCode)
- ceil(matrix, 3)
- np.testing.assert_array_equal(matrix, np.array([[1, 2], [3, 3]]))
-
- # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap
- def testCeilWrongDim(self):
- "Test ceil function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Matrix.__dict__[self.typeStr + "Ceil"]
- matrix = np.array([1, 2, 3, 4], self.typeCode)
- self.assertRaises(TypeError, ceil, matrix)
-
- # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap
- def testCeilWrongType(self):
- "Test ceil function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Matrix.__dict__[self.typeStr + "Ceil"]
- matrix = np.array([[1, 2], [3, 4]], 'c')
- self.assertRaises(TypeError, ceil, matrix)
-
- # Test (int DIM1, int DIM2, type* INPLACE_ARRAY2) typemap
- def testCeilNonArray(self):
- "Test ceil function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Matrix.__dict__[self.typeStr + "Ceil"]
- matrix = [[1, 2], [3, 4]]
- self.assertRaises(TypeError, ceil, matrix)
-
- # Test (type ARGOUT_ARRAY2[ANY][ANY]) typemap
- def testLUSplit(self):
- "Test luSplit function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- luSplit = Matrix.__dict__[self.typeStr + "LUSplit"]
- lower, upper = luSplit([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
- self.assertEquals((lower == [[1, 0, 0], [4, 5, 0], [7, 8, 9]]).all(), True)
- self.assertEquals((upper == [[0, 2, 3], [0, 0, 6], [0, 0, 0]]).all(), True)
-
-######################################################################
-
-class scharTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "schar"
- self.typeCode = "b"
-
-######################################################################
-
-class ucharTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "uchar"
- self.typeCode = "B"
-
-######################################################################
-
-class shortTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "short"
- self.typeCode = "h"
-
-######################################################################
-
-class ushortTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "ushort"
- self.typeCode = "H"
-
-######################################################################
-
-class intTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "int"
- self.typeCode = "i"
-
-######################################################################
-
-class uintTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "uint"
- self.typeCode = "I"
-
-######################################################################
-
-class longTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "long"
- self.typeCode = "l"
-
-######################################################################
-
-class ulongTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "ulong"
- self.typeCode = "L"
-
-######################################################################
-
-class longLongTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "longLong"
- self.typeCode = "q"
-
-######################################################################
-
-class ulongLongTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "ulongLong"
- self.typeCode = "Q"
-
-######################################################################
-
-class floatTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__init__(self, methodName)
- self.typeStr = "float"
- self.typeCode = "f"
-
-######################################################################
-
-class doubleTestCase(MatrixTestCase):
- def __init__(self, methodName="runTest"):
- MatrixTestCase.__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 2D Functions of Module Matrix")
- print("NumPy version", np.__version__)
- print()
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- sys.exit(len(result.errors) + len(result.failures))
diff --git a/doc/swig/test/testSuperTensor.py b/doc/swig/test/testSuperTensor.py
deleted file mode 100644
index ff1f86df2..000000000
--- a/doc/swig/test/testSuperTensor.py
+++ /dev/null
@@ -1,388 +0,0 @@
-#! /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))
diff --git a/doc/swig/test/testTensor.py b/doc/swig/test/testTensor.py
deleted file mode 100755
index a9390ebb1..000000000
--- a/doc/swig/test/testTensor.py
+++ /dev/null
@@ -1,402 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, absolute_import, print_function
-
-# 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 Tensor
-
-######################################################################
-
-class TensorTestCase(unittest.TestCase):
-
- def __init__(self, methodName="runTests"):
- unittest.TestCase.__init__(self, methodName)
- self.typeStr = "double"
- self.typeCode = "d"
- self.result = sqrt(28.0/8)
-
- # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
- def testNorm(self):
- "Test norm function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- norm = Tensor.__dict__[self.typeStr + "Norm"]
- tensor = [[[0, 1], [2, 3]],
- [[3, 2], [1, 0]]]
- if isinstance(self.result, int):
- self.assertEquals(norm(tensor), self.result)
- else:
- self.assertAlmostEqual(norm(tensor), self.result, 6)
-
- # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
- def testNormBadList(self):
- "Test norm function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- norm = Tensor.__dict__[self.typeStr + "Norm"]
- tensor = [[[0, "one"], [2, 3]],
- [[3, "two"], [1, 0]]]
- self.assertRaises(BadListError, norm, tensor)
-
- # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
- def testNormWrongDim(self):
- "Test norm function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- norm = Tensor.__dict__[self.typeStr + "Norm"]
- tensor = [[0, 1, 2, 3],
- [3, 2, 1, 0]]
- self.assertRaises(TypeError, norm, tensor)
-
- # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
- def testNormWrongSize(self):
- "Test norm function with wrong size"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- norm = Tensor.__dict__[self.typeStr + "Norm"]
- tensor = [[[0, 1, 0], [2, 3, 2]],
- [[3, 2, 3], [1, 0, 1]]]
- self.assertRaises(TypeError, norm, tensor)
-
- # Test (type IN_ARRAY3[ANY][ANY][ANY]) typemap
- def testNormNonContainer(self):
- "Test norm function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- norm = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Tensor.__dict__[self.typeStr + "Max"]
- tensor = [[[1, 2], [3, 4]],
- [[5, 6], [7, 8]]]
- self.assertEquals(max(tensor), 8)
-
- # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
- def testMaxBadList(self):
- "Test max function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Tensor.__dict__[self.typeStr + "Max"]
- tensor = [[[1, "two"], [3, 4]],
- [[5, "six"], [7, 8]]]
- self.assertRaises(BadListError, max, tensor)
-
- # Test (type* IN_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
- def testMaxNonContainer(self):
- "Test max function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- max = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Tensor.__dict__[self.typeStr + "Min"]
- tensor = [[[9, 8], [7, 6]],
- [[5, 4], [3, 2]]]
- self.assertEquals(min(tensor), 2)
-
- # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
- def testMinBadList(self):
- "Test min function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Tensor.__dict__[self.typeStr + "Min"]
- tensor = [[["nine", 8], [7, 6]],
- [["five", 4], [3, 2]]]
- self.assertRaises(BadListError, min, tensor)
-
- # Test (int DIM1, int DIM2, int DIM3, type* IN_ARRAY3) typemap
- def testMinNonContainer(self):
- "Test min function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- min = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Tensor.__dict__[self.typeStr + "Scale"]
- tensor = 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]]], self.typeCode)
- scale(tensor, 4)
- self.assertEquals((tensor == [[[4, 0, 4], [0, 4, 0], [4, 0, 4]],
- [[0, 4, 0], [4, 0, 4], [0, 4, 0]],
- [[4, 0, 4], [0, 4, 0], [4, 0, 4]]]).all(), True)
-
- # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
- def testScaleWrongType(self):
- "Test scale function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Tensor.__dict__[self.typeStr + "Scale"]
- tensor = 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, tensor)
-
- # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
- def testScaleWrongDim(self):
- "Test scale function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Tensor.__dict__[self.typeStr + "Scale"]
- tensor = 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, tensor)
-
- # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
- def testScaleWrongSize(self):
- "Test scale function with wrong size"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Tensor.__dict__[self.typeStr + "Scale"]
- tensor = 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, tensor)
-
- # Test (type INPLACE_ARRAY3[ANY][ANY][ANY]) typemap
- def testScaleNonArray(self):
- "Test scale function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- scale = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Tensor.__dict__[self.typeStr + "Floor"]
- tensor = np.array([[[1, 2], [3, 4]],
- [[5, 6], [7, 8]]], self.typeCode)
- floor(tensor, 4)
- np.testing.assert_array_equal(tensor, np.array([[[4, 4], [4, 4]],
- [[5, 6], [7, 8]]]))
-
- # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
- def testFloorWrongType(self):
- "Test floor function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Tensor.__dict__[self.typeStr + "Floor"]
- tensor = np.array([[[1, 2], [3, 4]],
- [[5, 6], [7, 8]]], 'c')
- self.assertRaises(TypeError, floor, tensor)
-
- # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
- def testFloorWrongDim(self):
- "Test floor function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Tensor.__dict__[self.typeStr + "Floor"]
- tensor = np.array([[1, 2], [3, 4], [5, 6], [7, 8]], self.typeCode)
- self.assertRaises(TypeError, floor, tensor)
-
- # Test (type* INPLACE_ARRAY3, int DIM1, int DIM2, int DIM3) typemap
- def testFloorNonArray(self):
- "Test floor function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- floor = Tensor.__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(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Tensor.__dict__[self.typeStr + "Ceil"]
- tensor = np.array([[[9, 8], [7, 6]],
- [[5, 4], [3, 2]]], self.typeCode)
- ceil(tensor, 5)
- np.testing.assert_array_equal(tensor, np.array([[[5, 5], [5, 5]],
- [[5, 4], [3, 2]]]))
-
- # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
- def testCeilWrongType(self):
- "Test ceil function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Tensor.__dict__[self.typeStr + "Ceil"]
- tensor = np.array([[[9, 8], [7, 6]],
- [[5, 4], [3, 2]]], 'c')
- self.assertRaises(TypeError, ceil, tensor)
-
- # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
- def testCeilWrongDim(self):
- "Test ceil function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Tensor.__dict__[self.typeStr + "Ceil"]
- tensor = np.array([[9, 8], [7, 6], [5, 4], [3, 2]], self.typeCode)
- self.assertRaises(TypeError, ceil, tensor)
-
- # Test (int DIM1, int DIM2, int DIM3, type* INPLACE_ARRAY3) typemap
- def testCeilNonArray(self):
- "Test ceil function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ceil = Tensor.__dict__[self.typeStr + "Ceil"]
- tensor = [[[9, 8], [7, 6]],
- [[5, 4], [3, 2]]]
- self.assertRaises(TypeError, ceil, tensor)
-
- # Test (type ARGOUT_ARRAY3[ANY][ANY][ANY]) typemap
- def testLUSplit(self):
- "Test luSplit function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- luSplit = Tensor.__dict__[self.typeStr + "LUSplit"]
- lower, upper = luSplit([[[1, 1], [1, 1]],
- [[1, 1], [1, 1]]])
- self.assertEquals((lower == [[[1, 1], [1, 0]],
- [[1, 0], [0, 0]]]).all(), True)
- self.assertEquals((upper == [[[0, 0], [0, 1]],
- [[0, 1], [1, 1]]]).all(), True)
-
-######################################################################
-
-class scharTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "schar"
- self.typeCode = "b"
- self.result = int(self.result)
-
-######################################################################
-
-class ucharTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "uchar"
- self.typeCode = "B"
- self.result = int(self.result)
-
-######################################################################
-
-class shortTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "short"
- self.typeCode = "h"
- self.result = int(self.result)
-
-######################################################################
-
-class ushortTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "ushort"
- self.typeCode = "H"
- self.result = int(self.result)
-
-######################################################################
-
-class intTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "int"
- self.typeCode = "i"
- self.result = int(self.result)
-
-######################################################################
-
-class uintTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "uint"
- self.typeCode = "I"
- self.result = int(self.result)
-
-######################################################################
-
-class longTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "long"
- self.typeCode = "l"
- self.result = int(self.result)
-
-######################################################################
-
-class ulongTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "ulong"
- self.typeCode = "L"
- self.result = int(self.result)
-
-######################################################################
-
-class longLongTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "longLong"
- self.typeCode = "q"
- self.result = int(self.result)
-
-######################################################################
-
-class ulongLongTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "ulongLong"
- self.typeCode = "Q"
- self.result = int(self.result)
-
-######################################################################
-
-class floatTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__init__(self, methodName)
- self.typeStr = "float"
- self.typeCode = "f"
-
-######################################################################
-
-class doubleTestCase(TensorTestCase):
- def __init__(self, methodName="runTest"):
- TensorTestCase.__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 3D Functions of Module Tensor")
- print("NumPy version", np.__version__)
- print()
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- sys.exit(len(result.errors) + len(result.failures))
diff --git a/doc/swig/test/testVector.py b/doc/swig/test/testVector.py
deleted file mode 100755
index e7d019cf7..000000000
--- a/doc/swig/test/testVector.py
+++ /dev/null
@@ -1,381 +0,0 @@
-#! /usr/bin/env python
-from __future__ import division, absolute_import, print_function
-
-# System imports
-from distutils.util import get_platform
-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 Vector
-
-######################################################################
-
-class VectorTestCase(unittest.TestCase):
-
- def __init__(self, methodName="runTest"):
- unittest.TestCase.__init__(self, methodName)
- self.typeStr = "double"
- self.typeCode = "d"
-
- # Test the (type IN_ARRAY1[ANY]) typemap
- def testLength(self):
- "Test length function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- length = Vector.__dict__[self.typeStr + "Length"]
- self.assertEquals(length([5, 12, 0]), 13)
-
- # Test the (type IN_ARRAY1[ANY]) typemap
- def testLengthBadList(self):
- "Test length function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- length = Vector.__dict__[self.typeStr + "Length"]
- self.assertRaises(BadListError, length, [5, "twelve", 0])
-
- # Test the (type IN_ARRAY1[ANY]) typemap
- def testLengthWrongSize(self):
- "Test length function with wrong size"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- length = Vector.__dict__[self.typeStr + "Length"]
- self.assertRaises(TypeError, length, [5, 12])
-
- # Test the (type IN_ARRAY1[ANY]) typemap
- def testLengthWrongDim(self):
- "Test length function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- length = Vector.__dict__[self.typeStr + "Length"]
- self.assertRaises(TypeError, length, [[1, 2], [3, 4]])
-
- # Test the (type IN_ARRAY1[ANY]) typemap
- def testLengthNonContainer(self):
- "Test length function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- length = Vector.__dict__[self.typeStr + "Length"]
- self.assertRaises(TypeError, length, None)
-
- # Test the (type* IN_ARRAY1, int DIM1) typemap
- def testProd(self):
- "Test prod function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- prod = Vector.__dict__[self.typeStr + "Prod"]
- self.assertEquals(prod([1, 2, 3, 4]), 24)
-
- # Test the (type* IN_ARRAY1, int DIM1) typemap
- def testProdBadList(self):
- "Test prod function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- prod = Vector.__dict__[self.typeStr + "Prod"]
- self.assertRaises(BadListError, prod, [[1, "two"], ["e", "pi"]])
-
- # Test the (type* IN_ARRAY1, int DIM1) typemap
- def testProdWrongDim(self):
- "Test prod function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- prod = Vector.__dict__[self.typeStr + "Prod"]
- self.assertRaises(TypeError, prod, [[1, 2], [8, 9]])
-
- # Test the (type* IN_ARRAY1, int DIM1) typemap
- def testProdNonContainer(self):
- "Test prod function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- prod = Vector.__dict__[self.typeStr + "Prod"]
- self.assertRaises(TypeError, prod, None)
-
- # Test the (int DIM1, type* IN_ARRAY1) typemap
- def testSum(self):
- "Test sum function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- sum = Vector.__dict__[self.typeStr + "Sum"]
- self.assertEquals(sum([5, 6, 7, 8]), 26)
-
- # Test the (int DIM1, type* IN_ARRAY1) typemap
- def testSumBadList(self):
- "Test sum function with bad list"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- sum = Vector.__dict__[self.typeStr + "Sum"]
- self.assertRaises(BadListError, sum, [3, 4, 5, "pi"])
-
- # Test the (int DIM1, type* IN_ARRAY1) typemap
- def testSumWrongDim(self):
- "Test sum function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- sum = Vector.__dict__[self.typeStr + "Sum"]
- self.assertRaises(TypeError, sum, [[3, 4], [5, 6]])
-
- # Test the (int DIM1, type* IN_ARRAY1) typemap
- def testSumNonContainer(self):
- "Test sum function with non-container"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- sum = Vector.__dict__[self.typeStr + "Sum"]
- self.assertRaises(TypeError, sum, True)
-
- # Test the (type INPLACE_ARRAY1[ANY]) typemap
- def testReverse(self):
- "Test reverse function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- reverse = Vector.__dict__[self.typeStr + "Reverse"]
- vector = np.array([1, 2, 4], self.typeCode)
- reverse(vector)
- self.assertEquals((vector == [4, 2, 1]).all(), True)
-
- # Test the (type INPLACE_ARRAY1[ANY]) typemap
- def testReverseWrongDim(self):
- "Test reverse function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- reverse = Vector.__dict__[self.typeStr + "Reverse"]
- vector = np.array([[1, 2], [3, 4]], self.typeCode)
- self.assertRaises(TypeError, reverse, vector)
-
- # Test the (type INPLACE_ARRAY1[ANY]) typemap
- def testReverseWrongSize(self):
- "Test reverse function with wrong size"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- reverse = Vector.__dict__[self.typeStr + "Reverse"]
- vector = np.array([9, 8, 7, 6, 5, 4], self.typeCode)
- self.assertRaises(TypeError, reverse, vector)
-
- # Test the (type INPLACE_ARRAY1[ANY]) typemap
- def testReverseWrongType(self):
- "Test reverse function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- reverse = Vector.__dict__[self.typeStr + "Reverse"]
- vector = np.array([1, 2, 4], 'c')
- self.assertRaises(TypeError, reverse, vector)
-
- # Test the (type INPLACE_ARRAY1[ANY]) typemap
- def testReverseNonArray(self):
- "Test reverse function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- reverse = Vector.__dict__[self.typeStr + "Reverse"]
- self.assertRaises(TypeError, reverse, [2, 4, 6])
-
- # Test the (type* INPLACE_ARRAY1, int DIM1) typemap
- def testOnes(self):
- "Test ones function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ones = Vector.__dict__[self.typeStr + "Ones"]
- vector = np.zeros(5, self.typeCode)
- ones(vector)
- np.testing.assert_array_equal(vector, np.array([1, 1, 1, 1, 1]))
-
- # Test the (type* INPLACE_ARRAY1, int DIM1) typemap
- def testOnesWrongDim(self):
- "Test ones function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ones = Vector.__dict__[self.typeStr + "Ones"]
- vector = np.zeros((5, 5), self.typeCode)
- self.assertRaises(TypeError, ones, vector)
-
- # Test the (type* INPLACE_ARRAY1, int DIM1) typemap
- def testOnesWrongType(self):
- "Test ones function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ones = Vector.__dict__[self.typeStr + "Ones"]
- vector = np.zeros((5, 5), 'c')
- self.assertRaises(TypeError, ones, vector)
-
- # Test the (type* INPLACE_ARRAY1, int DIM1) typemap
- def testOnesNonArray(self):
- "Test ones function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- ones = Vector.__dict__[self.typeStr + "Ones"]
- self.assertRaises(TypeError, ones, [2, 4, 6, 8])
-
- # Test the (int DIM1, type* INPLACE_ARRAY1) typemap
- def testZeros(self):
- "Test zeros function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- zeros = Vector.__dict__[self.typeStr + "Zeros"]
- vector = np.ones(5, self.typeCode)
- zeros(vector)
- np.testing.assert_array_equal(vector, np.array([0, 0, 0, 0, 0]))
-
- # Test the (int DIM1, type* INPLACE_ARRAY1) typemap
- def testZerosWrongDim(self):
- "Test zeros function with wrong dimensions"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- zeros = Vector.__dict__[self.typeStr + "Zeros"]
- vector = np.ones((5, 5), self.typeCode)
- self.assertRaises(TypeError, zeros, vector)
-
- # Test the (int DIM1, type* INPLACE_ARRAY1) typemap
- def testZerosWrongType(self):
- "Test zeros function with wrong type"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- zeros = Vector.__dict__[self.typeStr + "Zeros"]
- vector = np.ones(6, 'c')
- self.assertRaises(TypeError, zeros, vector)
-
- # Test the (int DIM1, type* INPLACE_ARRAY1) typemap
- def testZerosNonArray(self):
- "Test zeros function with non-array"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- zeros = Vector.__dict__[self.typeStr + "Zeros"]
- self.assertRaises(TypeError, zeros, [1, 3, 5, 7, 9])
-
- # Test the (type ARGOUT_ARRAY1[ANY]) typemap
- def testEOSplit(self):
- "Test eoSplit function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- eoSplit = Vector.__dict__[self.typeStr + "EOSplit"]
- even, odd = eoSplit([1, 2, 3])
- self.assertEquals((even == [1, 0, 3]).all(), True)
- self.assertEquals((odd == [0, 2, 0]).all(), True)
-
- # Test the (type* ARGOUT_ARRAY1, int DIM1) typemap
- def testTwos(self):
- "Test twos function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- twos = Vector.__dict__[self.typeStr + "Twos"]
- vector = twos(5)
- self.assertEquals((vector == [2, 2, 2, 2, 2]).all(), True)
-
- # Test the (type* ARGOUT_ARRAY1, int DIM1) typemap
- def testTwosNonInt(self):
- "Test twos function with non-integer dimension"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- twos = Vector.__dict__[self.typeStr + "Twos"]
- self.assertRaises(TypeError, twos, 5.0)
-
- # Test the (int DIM1, type* ARGOUT_ARRAY1) typemap
- def testThrees(self):
- "Test threes function"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- threes = Vector.__dict__[self.typeStr + "Threes"]
- vector = threes(6)
- self.assertEquals((vector == [3, 3, 3, 3, 3, 3]).all(), True)
-
- # Test the (type* ARGOUT_ARRAY1, int DIM1) typemap
- def testThreesNonInt(self):
- "Test threes function with non-integer dimension"
- print(self.typeStr, "... ", end=' ', file=sys.stderr)
- threes = Vector.__dict__[self.typeStr + "Threes"]
- self.assertRaises(TypeError, threes, "threes")
-
-######################################################################
-
-class scharTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "schar"
- self.typeCode = "b"
-
-######################################################################
-
-class ucharTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "uchar"
- self.typeCode = "B"
-
-######################################################################
-
-class shortTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "short"
- self.typeCode = "h"
-
-######################################################################
-
-class ushortTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "ushort"
- self.typeCode = "H"
-
-######################################################################
-
-class intTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "int"
- self.typeCode = "i"
-
-######################################################################
-
-class uintTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "uint"
- self.typeCode = "I"
-
-######################################################################
-
-class longTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "long"
- self.typeCode = "l"
-
-######################################################################
-
-class ulongTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "ulong"
- self.typeCode = "L"
-
-######################################################################
-
-class longLongTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "longLong"
- self.typeCode = "q"
-
-######################################################################
-
-class ulongLongTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "ulongLong"
- self.typeCode = "Q"
-
-######################################################################
-
-class floatTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__init__(self, methodName)
- self.typeStr = "float"
- self.typeCode = "f"
-
-######################################################################
-
-class doubleTestCase(VectorTestCase):
- def __init__(self, methodName="runTest"):
- VectorTestCase.__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 1D Functions of Module Vector")
- print("NumPy version", np.__version__)
- print()
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- sys.exit(len(result.errors) + len(result.failures))