source: trunk/ADOL-C/swig/numpy.i @ 764

Last change on this file since 764 was 764, checked in by mbanovic, 4 months ago

Merge branch swig into svn.

The following commits have been merged:

commit 15c64c07d051ef872afd8bc04f772624ac3c0580
Merge: a22cb31 617f278
Author: Mladen Banovic <mladenbanovic2705@…>
Date: Wed Jan 30 14:53:13 2019 +0100

Merge branch 'swig'

commit 617f2781bde18dd7c58f3a2554dec70d94cedd92
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 16:23:11 2018 +0100

remove unnecessary %include

commit b7718a5407516afea3b1dabafeb3fa084a9b1ab3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 16:12:06 2018 +0100

fix destructors for EDF classes

commit 79ae7862f370fbbc04033d42cfd796b429c19e5f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 15:52:29 2018 +0100

improve test.py example

commit 0dbe7842bde1f9f92909fed8459e8298183c7890
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 15:47:43 2018 +0100

add python examples

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 08ae3d98cadfb86016a48322319548d549ae3418
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Dec 21 15:47:14 2018 +0100

Make external functions work

EDFobject_v2 is not implemented yet

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit acfd9c5e41c2c2e99d7e530f0837dd6a5b0dac96
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Dec 11 12:07:01 2018 +0100

regenerate doc

commit c673f73ee35f8b8ce74258add01e085e68c0c13a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Dec 11 12:06:21 2018 +0100

add python and R installation to doc

commit 317c3c5a6744d38091e809d804c23d637d900fe9
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Wed Jun 13 15:21:36 2018 +0000

make init_lib() static to avoid name clashes in other units

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@758 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit 9a291b9b5646ae665382efafc3e9993c51aa4bc0
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Wed Jun 13 15:02:22 2018 +0000

rename void init() to void init_lib()

this function is totally internal to tape_handling.cpp and called
from the constructor of Keeper class. However the name init() seems to refer
to something else in the scope of the class and correct initialization
isn't done, causing errors later.

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@757 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit f84f47f5f12c9a69ef44ccefe1b654fa3524cda3
Merge: 5021e4a 6c0d2d5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Oct 11 21:53:14 2017 +0200

Merge branch 'swig' of gitlab.com:adol-c/adol-c into swig

commit 5021e4ab8cab3fd0760635e13c1a59e25f3c7eb6
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Oct 11 21:44:36 2017 +0200

add abs and rename asin/acos/atan to arcsin/arccos/arctan etc

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6c0d2d5c9c90350b384b360dfb9659c9f2ca4bd6
Merge: cba0df1 2444ff3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Oct 5 19:39:47 2017 +0000

Merge branch 'swig' into 'swig'

Python setup.py and R interface

See merge request adol-c/adol-c!11

commit 2444ff3a28e4a33a4670c8ebf6956f7c85a2274e
Merge: 068b059 946c873
Author: Sri Hari Krishna Narayanan <snarayan@…>
Date: Thu Oct 5 12:26:38 2017 -0500

Merge branch 'swig' of gitlab.com:sriharikrishna/adol-c into swig

commit 068b0592f59cbd11a434dca90be74ffbb767bde3
Author: Sri Hari Krishna Narayanan <snarayan@…>
Date: Thu Oct 5 12:19:52 2017 -0500

Change all use of clib to lib

commit ac987aca06b5c932adbd31bcf08811008b325257
Author: Sri Hari Krishna Narayanan <snarayan@…>
Date: Thu Oct 5 12:10:27 2017 -0500

Add python linking libraries

commit cba0df178387670ec3a1b94c237e13542090e78d
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Sep 5 13:37:03 2017 +0200

make psdrivers numpy conformant and remove one warning

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e450b62a4b3e501e9940400137fc89351dbdb8ba
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Sep 5 13:35:07 2017 +0200

Make interface of psdrivers conformant and remove redundant parameter

Letters are as represented in the 2017 OMS paper.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 83c5f035130849b98a299857c7c5524a6ffb29a2
Merge: a50a2e1 363e176
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Aug 3 14:05:37 2017 +0200

Merge branch 'master' into swig

commit a50a2e19f79d3178592948c400d6eb89ed828b06
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 22 13:52:26 2017 +0200

make setup.py install do everything

Of course this assumes you have autotools, libtool, and C++ compiler
previously installed as well as boost library and colpack.

commit 1a5f22002c83b99e8d69c297ae89cb03cc304e50
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 22 13:51:41 2017 +0200

add missing support for numpy.sqrt

this was seemingly just oversight

commit f06f5011e183a203eca79444d6b175556f242f6a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Jun 16 12:43:46 2017 +0200

add a setup.py for compatibilty with python installers

like pip or anaconda. In this case the setup.py will compile the C/C++
original library as well as the swig wrapper.
arguments to build are:
--lib-prefix=<DIR>

will install the C/C++ library andn headers in <DIR>/include <DIR>/lib64

--colpack-dir=<DIR>

will assume that ColPack? is installed in <DIR>/include and <DIR>/lib64

--boost-dir=<DIR>

will assume that boost is installed in <DIR>/include and <DIR>/lib64

I haven't tested on anything except 64-bit linux until now.

for install I've only tested installing with --user option

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit cd793f6a8503a1e3751cfaeb843af249c522ce46
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri May 5 10:16:23 2017 +0200

a slightly more meaningful naming

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 4c2a248fe5937daf292948e8ace9af0e4ccdffc1
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri May 5 10:08:24 2017 +0200

Fix Python Exception properly

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit f272c673fcb0941f3f054462eb9843be4e8b829a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Apr 26 17:29:37 2017 +0200

export the cleanUp() function for wrappers

commit 0ed3a9394d3ed0e2804a3cef8b39dba105817e84
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Apr 19 18:09:39 2017 +0200

python3 compatibility and slight change in swigprocess.py

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c085c16e96c2f5bce7f4a50a77d4164bcaa47cf6
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Feb 16 15:58:46 2017 +0100

add headers for implicit inclusions in edfclasses.h

commit 239078661e4d41e6ecdb131311f2fafe560874f3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Feb 16 09:24:17 2017 +0100

add support for vectors and matrices in octave drivers

forward and reverse drivers to come. sparse drivers to come

commit 19e89992da84bdf392233c8add69d02bed714e60
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 22 10:24:44 2016 +0100

Add swig interface for octave

commit 76a264d5412c5599102a4c9a182d3163a6ab6851
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Nov 18 15:49:36 2016 +0100

rename persistent local header to .hpp

since it is a c++ header. And some temporary .h files are created that
will require cleaning in 'make clean'

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b59d463221a708e98af350decd97bdd26feb27d7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Nov 18 14:01:19 2016 +0100

reorder some lines to fix compilation and %ignore issues

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 26535bfc6d9db954c246d991b5ef09d8cd8d66d1
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Nov 17 10:43:14 2016 +0100

Add directors for python extension of edfclasses.h

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c522a5f6400e819eb393cfe44a68cae06fbb9ffe
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Nov 2 14:26:11 2016 -0500

call() must not be overloaded by child classes either

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 98fc1f127e71c3ffef73ed43525cd21ec45942b1
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Nov 2 14:19:59 2016 -0500

init_edf() must not be overloaded by child classes

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 1e5e0c68a7a0ff3369e9a3991edaa7d04164a3e5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Nov 2 14:05:40 2016 -0500

design a C++ object oriented wrapper for external functions

it is easier to work with classes, inheritence and overloaded member
functions in scripting languages like python and R instead of raw
pointers to functions in order to call arbitrary code.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 782465d4175a2453934cd1ffe9649e3f78a42c75
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Sep 14 09:49:12 2016 +0200

add support for calling numpy.cos and friends on adouble arrays

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b0ed723914bdc46ce9128727972dc287288b0a71
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 18:28:43 2016 +0200

helper for printing exception

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6f263543749e7fcb688e8af5cde68da3745886b5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 18:06:59 2016 +0200

expose FatalError? to swig python interface

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 7f579bb5629eb5f5c5a49ce4d0484a306640748d
Merge: d2f49d3 3bbd2a2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 17:54:41 2016 +0200

Merge branch 'master' into swig

commit d2f49d373e00f583e9b7c0ee69c160fbae1322c7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:37:10 2016 +0200

improve logic in fmin and fmax

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e138ca65b6361b23a4000c77128d0ed684662e1c
Merge: cafefb7 3c5e311
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:31:06 2016 +0200

Merge remote-tracking branch 'origin/swig' into swig

commit cafefb7081ff8d5ba7c772b5b022404101b813e0
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:30:32 2016 +0200

wrap newly added functions in master branch

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ff975ebd035995f0e9dc01578ac3e84b91b1604f
Merge: 02e32a7 4c79b27
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:11:42 2016 +0200

Merge remote-tracking branch 'origin/master' into swig

commit 02e32a7aa72d4310238f7ae9b85a52e29b46cf4a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Aug 10 13:09:31 2016 +0200

add fmin, fmax, fabs, and printTapeStats for swig-python

fmin, fmax and fabs should work on scalars as well as badoubles

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 3c5e3112cdb978f0274f4d6cacd128abc034ff9b
Merge: dd06803 7aa4b9a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Aug 8 13:37:12 2016 +0200

Merge branch 'master' into swig

commit dd06803b3f40b3057976c315241f583bc0007397
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Aug 4 15:08:45 2016 +0200

raise exceptions for retracing in python

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit d253dfaa74f38b5b545f4f88ba08d86a65aa960a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 13:49:16 2016 +0200

fix typo in variable name

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ade470ecf44fad03025ef9fcfadc5cac5d3e9f80
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 11:36:06 2016 +0200

handle locint as an unsigned long

for some reason swig doesn't do this on it's own.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e60c95d9dd70d962aed3caed4e05d0ef48ffcab2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 11:04:44 2016 +0200

use the compiler set up in ${CXX}

if ${CXX} is not set it defaults to 'c++'

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 42b439a47e2601325cb4d02aa27ac4b9c0535eea
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 03:12:12 2016 +0200

add numpy compatible set_param_vec()

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 774a2204590aeb57cbc18e654bc6fe21763142c2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 21 02:41:22 2016 +0200

add function to convert numpy arrays directly to adouble arrays

works for any contiguous iterable type like list, tuple etc.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c3e04155d83b3ee76df294c2adea78ca1df865f0
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 14 10:57:43 2016 +0200

refresh swig patches for current swig master branch

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 48e0ef1cf7650d5b2e232d0d5450a158080d7849
Merge: 52445e4 06427e9
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jul 14 10:36:59 2016 +0200

Merge branch 'master' into swig

commit 52445e41a8b768299084702418973ec79bd972c2
Merge: 666ba79 7507929
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 23 14:59:05 2016 +0100

Merge branch 'master' into swig

commit 666ba7931e001bfd78171c7347b400b359dbd2d2
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 23 14:58:59 2016 +0100

add reverse drivers and use kwargs for overloaded forward/reverse call

also add tapestats.
more reverse drivers coming.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c16bf7ff198728740896a804d85684c0575c1e47
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 16:08:10 2016 +0100

add conversion for contiguous matrices and tensors

this time in the swig interface only, because they aren't
needed anywhere else.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit f3895ffd1dbb07b8a04e867982683ae8de7a5052
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 15:45:22 2016 +0100

Revert "add conversion for contiguous matrices and tensors"

This reverts commit 7ad2746027b650147ec1d2da6567a3e5a7ecb876.

commit 76eb5d0899280cb9e3b4f4c1902823a45e884774
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 13:46:12 2016 +0100

change forward drivers to return numpy arrays

instead of expecting inplace arguments

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 73bde825b256809ae07d124c1c6c66e9ae50eb82
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 21 12:57:20 2016 +0100

change drivers to return numpy arrays

instead of expecting inplace arguments for output

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 946c87335675e68b7ea826eadd801d8d6fca4f54
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 17 07:55:25 2016 -0500

R: Added special handling for sparse_jac

commit 74d1c42cf5704c5ed7ae193cab6b2344334219c5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Mar 15 14:32:47 2016 +0100

fix inclusion of sparse drivers for swig (and other users)

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e97a73cc2a33645c517a83367d3e709ff3f4a244
Merge: de9eef7 dbc9f38
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:52:57 2016 +0000

Merge branch 'swig' into 'swig'

Swig/R

Cleanup

See merge request !4

commit dbc9f3847b58781367d8bcfd0545f3283d3ce350
Merge: b2dd718 de9eef7
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:45:26 2016 -0600

Merge remote-tracking branch 'origin/swig' into swig

commit b2dd71855ce277d4f956c99f04e03f954b0ff344
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:45:01 2016 -0600

R: removed extraneous pragmas

commit de9eef7ce7ba0d5a4256018f4d0bbf79bba25f7f
Merge: 0096858 fdaa52b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:37:21 2016 +0000

Merge branch 'swig' into 'swig'

Swig/R

Bugfixes for SWIG/R interface

See merge request !3

commit fdaa52bf6654fa2558c2982738f4de1f49c2c960
Merge: 2fa790a 0096858
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:20:57 2016 -0600

Merge remote-tracking branch 'origin/swig' into swig

commit 2fa790a85c04b41755e5587baa21e59fe7416ab9
Author: Sri Hari Krishna Narayanan <sriharikrishna@…>
Date: Thu Mar 10 16:13:41 2016 -0600

R: debug all SWIG and R related bugs.

SWIG 3.0.8 needs the two patches and the generated adolc.R needs
the diff. Then ADOL-C can be imported into the R runtime by
source ("init_adolc.R")

commit 009685847f9d81b97d7efcc85d02aa7325bb6b6a
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:05:52 2016 +0100

reflect file rename in Makefile.am for packaging

commit 9c10d2065974fe1afba0284f5970e55f2e7f28b7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:05:04 2016 +0100

add numpy implementation for common drivers

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 08b723756aa4e6ab2e6ff3f6c3d532691c831019
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 22:04:26 2016 +0100

change header extension to .hpp to suppress clang warning

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 109cb5ca0ae4c07592854af2a48cb6935e2e629b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 20:51:16 2016 +0100

numpy: Be more verbose in error message for mismatch of dimension

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit d76918c8e2306ca2e13665fae7feb183b45652aa
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 19:58:08 2016 +0100

more licensing info

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 075bda30cf9d1a6432a9db4e587d6f3897ec8f1d
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 18:47:47 2016 +0100

compile interface based on choice

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit c368a02f8d44ad772da5659234a8bdeed254ab7c
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 18:21:54 2016 +0100

add numpy support to python swig interface for forward mode

also in swigprocess compatibility with macosx and general bugfixing

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 7ad2746027b650147ec1d2da6567a3e5a7ecb876
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 10 18:13:35 2016 +0100

add conversion for contiguous matrices and tensors

Just a contiguous row major chunk for matrices ins't
good for indexing using 2 indices, we need to convert
it to double and add pointers. Similarly for tensors.

These will do just that, required for supporting numpy
arrays in the python swig interface

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 41cb636430fa636b4e25ab81da73d2e6fd741dec
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 17:08:03 2016 +0100

more verbosity for invoking shell commands

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 82ee8be28c090f84da7eb8a1254440d301fc5675
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 17:07:43 2016 +0100

add copyright and licensing everywhere

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e5ec0154c1743d68b28e3fba1864742b23e3715b
Merge: 6ac52a6 a539d68
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 16:28:40 2016 +0100

Merge branch 'master' into swig

commit 6ac52a6a45d8fc9c11c9b0c3b1d0399f6537eadc
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 3 16:28:33 2016 +0100

make script more verbose

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit a6ef9a80ea9593ea5f1861d3ff19315b92a75130
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Feb 2 08:09:26 2016 +0100

correction in documentation of sparse functions

commit dbd7a07a1f5bcd6871d9a728f34a3d0679e01e4f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 17 22:50:11 2015 +0100

add error handling and make script python3 compatible

the swig generated interface may still not be python3 compatible

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 35ee8b63bea8bf7a0dea7af0e85f69336c6702e5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 17 18:14:12 2015 +0100

define better python operators

just renaming doesn't work. Maybe we'll need something similar in R too
but since I don't know R, I can't say.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 9654fa7e3b2a83187ee828f2ec9b39e6300ecaa7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Dec 17 14:34:58 2015 +0100

Add a swig based python and R interface to ADOL-C

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File size: 106.1 KB
Line 
1/* -*- C -*-  (not really, but good for syntax highlighting) */
2
3/*
4 * Copyright (c) 2005-2015, NumPy Developers.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 *     * Redistributions of source code must retain the above copyright
12 *        notice, this list of conditions and the following disclaimer.
13 *
14 *     * Redistributions in binary form must reproduce the above
15 *        copyright notice, this list of conditions and the following
16 *        disclaimer in the documentation and/or other materials provided
17 *        with the distribution.
18 *
19 *     * Neither the name of the NumPy Developers nor the names of any
20 *        contributors may be used to endorse or promote products derived
21 *        from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifdef SWIGPYTHON
37
38%{
39#ifndef SWIG_FILE_WITH_INIT
40#define NO_IMPORT_ARRAY
41#endif
42#include "stdio.h"
43#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
44#include <numpy/arrayobject.h>
45%}
46
47/**********************************************************************/
48
49%fragment("NumPy_Backward_Compatibility", "header")
50{
51%#if NPY_API_VERSION < 0x00000007
52%#define NPY_ARRAY_DEFAULT NPY_DEFAULT
53%#define NPY_ARRAY_FARRAY  NPY_FARRAY
54%#define NPY_FORTRANORDER  NPY_FORTRAN
55%#endif
56}
57
58/**********************************************************************/
59
60/* The following code originally appeared in
61 * enthought/kiva/agg/src/numeric.i written by Eric Jones.  It was
62 * translated from C++ to C by John Hunter.  Bill Spotz has modified
63 * it to fix some minor bugs, upgrade from Numeric to numpy (all
64 * versions), add some comments and functionality, and convert from
65 * direct code insertion to SWIG fragments.
66 */
67
68%fragment("NumPy_Macros", "header")
69{
70/* Macros to extract array attributes.
71 */
72%#if NPY_API_VERSION < 0x00000007
73%#define is_array(a)            ((a) && PyArray_Check((PyArrayObject*)a))
74%#define array_type(a)          (int)(PyArray_TYPE((PyArrayObject*)a))
75%#define array_numdims(a)       (((PyArrayObject*)a)->nd)
76%#define array_dimensions(a)    (((PyArrayObject*)a)->dimensions)
77%#define array_size(a,i)        (((PyArrayObject*)a)->dimensions[i])
78%#define array_strides(a)       (((PyArrayObject*)a)->strides)
79%#define array_stride(a,i)      (((PyArrayObject*)a)->strides[i])
80%#define array_data(a)          (((PyArrayObject*)a)->data)
81%#define array_descr(a)         (((PyArrayObject*)a)->descr)
82%#define array_flags(a)         (((PyArrayObject*)a)->flags)
83%#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f
84%#else
85%#define is_array(a)            ((a) && PyArray_Check(a))
86%#define array_type(a)          PyArray_TYPE((PyArrayObject*)a)
87%#define array_numdims(a)       PyArray_NDIM((PyArrayObject*)a)
88%#define array_dimensions(a)    PyArray_DIMS((PyArrayObject*)a)
89%#define array_strides(a)       PyArray_STRIDES((PyArrayObject*)a)
90%#define array_stride(a,i)      PyArray_STRIDE((PyArrayObject*)a,i)
91%#define array_size(a,i)        PyArray_DIM((PyArrayObject*)a,i)
92%#define array_data(a)          PyArray_DATA((PyArrayObject*)a)
93%#define array_descr(a)         PyArray_DESCR((PyArrayObject*)a)
94%#define array_flags(a)         PyArray_FLAGS((PyArrayObject*)a)
95%#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f)
96%#endif
97%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a))
98%#define array_is_native(a)     (PyArray_ISNOTSWAPPED((PyArrayObject*)a))
99%#define array_is_fortran(a)    (PyArray_IS_F_CONTIGUOUS((PyArrayObject*)a))
100}
101
102/**********************************************************************/
103
104%fragment("NumPy_Utilities",
105          "header")
106{
107  /* Given a PyObject, return a string describing its type.
108   */
109  const char* pytype_string(PyObject* py_obj)
110  {
111    if (py_obj == NULL          ) return "C NULL value";
112    if (py_obj == Py_None       ) return "Python None" ;
113    if (PyCallable_Check(py_obj)) return "callable"    ;
114    if (PyString_Check(  py_obj)) return "string"      ;
115    if (PyInt_Check(     py_obj)) return "int"         ;
116    if (PyFloat_Check(   py_obj)) return "float"       ;
117    if (PyDict_Check(    py_obj)) return "dict"        ;
118    if (PyList_Check(    py_obj)) return "list"        ;
119    if (PyTuple_Check(   py_obj)) return "tuple"       ;
120%#if PY_MAJOR_VERSION < 3
121    if (PyFile_Check(    py_obj)) return "file"        ;
122    if (PyModule_Check(  py_obj)) return "module"      ;
123    if (PyInstance_Check(py_obj)) return "instance"    ;
124%#endif
125
126    return "unkown type";
127  }
128
129  /* Given a NumPy typecode, return a string describing the type.
130   */
131  const char* typecode_string(int typecode)
132  {
133    static const char* type_names[25] = {"bool",
134                                         "byte",
135                                         "unsigned byte",
136                                         "short",
137                                         "unsigned short",
138                                         "int",
139                                         "unsigned int",
140                                         "long",
141                                         "unsigned long",
142                                         "long long",
143                                         "unsigned long long",
144                                         "float",
145                                         "double",
146                                         "long double",
147                                         "complex float",
148                                         "complex double",
149                                         "complex long double",
150                                         "object",
151                                         "string",
152                                         "unicode",
153                                         "void",
154                                         "ntypes",
155                                         "notype",
156                                         "char",
157                                         "unknown"};
158    return typecode < 24 ? type_names[typecode] : type_names[24];
159  }
160
161  /* Make sure input has correct numpy type.  This now just calls
162     PyArray_EquivTypenums().
163   */
164  int type_match(int actual_type,
165                 int desired_type)
166  {
167    return PyArray_EquivTypenums(actual_type, desired_type);
168  }
169
170%#ifdef SWIGPY_USE_CAPSULE
171  void free_cap(PyObject * cap)
172  {
173    void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME);
174    if (array != NULL) free(array);
175  }
176%#endif
177
178
179}
180
181/**********************************************************************/
182
183%fragment("NumPy_Object_to_Array",
184          "header",
185          fragment="NumPy_Backward_Compatibility",
186          fragment="NumPy_Macros",
187          fragment="NumPy_Utilities")
188{
189  /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
190   * legal.  If not, set the python error string appropriately and
191   * return NULL.
192   */
193  PyArrayObject* obj_to_array_no_conversion(PyObject* input,
194                                            int        typecode)
195  {
196    PyArrayObject* ary = NULL;
197    if (is_array(input) && (typecode == NPY_NOTYPE ||
198                            PyArray_EquivTypenums(array_type(input), typecode)))
199    {
200      ary = (PyArrayObject*) input;
201    }
202    else if is_array(input)
203    {
204      const char* desired_type = typecode_string(typecode);
205      const char* actual_type  = typecode_string(array_type(input));
206      PyErr_Format(PyExc_TypeError,
207                   "Array of type '%s' required.  Array of type '%s' given",
208                   desired_type, actual_type);
209      ary = NULL;
210    }
211    else
212    {
213      const char* desired_type = typecode_string(typecode);
214      const char* actual_type  = pytype_string(input);
215      PyErr_Format(PyExc_TypeError,
216                   "Array of type '%s' required.  A '%s' was given",
217                   desired_type,
218                   actual_type);
219      ary = NULL;
220    }
221    return ary;
222  }
223
224  /* Convert the given PyObject to a NumPy array with the given
225   * typecode.  On success, return a valid PyArrayObject* with the
226   * correct type.  On failure, the python error string will be set and
227   * the routine returns NULL.
228   */
229  PyArrayObject* obj_to_array_allow_conversion(PyObject* input,
230                                               int       typecode,
231                                               int*      is_new_object)
232  {
233    PyArrayObject* ary = NULL;
234    PyObject*      py_obj;
235    if (is_array(input) && (typecode == NPY_NOTYPE ||
236                            PyArray_EquivTypenums(array_type(input),typecode)))
237    {
238      ary = (PyArrayObject*) input;
239      *is_new_object = 0;
240    }
241    else
242    {
243      py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_ARRAY_DEFAULT);
244      /* If NULL, PyArray_FromObject will have set python error value.*/
245      ary = (PyArrayObject*) py_obj;
246      *is_new_object = 1;
247    }
248    return ary;
249  }
250
251  /* Given a PyArrayObject, check to see if it is contiguous.  If so,
252   * return the input pointer and flag it as not a new object.  If it is
253   * not contiguous, create a new PyArrayObject using the original data,
254   * flag it as a new object and return the pointer.
255   */
256  PyArrayObject* make_contiguous(PyArrayObject* ary,
257                                 int*           is_new_object,
258                                 int            min_dims,
259                                 int            max_dims)
260  {
261    PyArrayObject* result;
262    if (array_is_contiguous(ary))
263    {
264      result = ary;
265      *is_new_object = 0;
266    }
267    else
268    {
269      result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
270                                                              array_type(ary),
271                                                              min_dims,
272                                                              max_dims);
273      *is_new_object = 1;
274    }
275    return result;
276  }
277
278  /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
279   * If so, return the input pointer, but do not flag it as not a new
280   * object.  If it is not Fortran-contiguous, create a new
281   * PyArrayObject using the original data, flag it as a new object
282   * and return the pointer.
283   */
284  PyArrayObject* make_fortran(PyArrayObject* ary,
285                              int*           is_new_object)
286  {
287    PyArrayObject* result;
288    if (array_is_fortran(ary))
289    {
290      result = ary;
291      *is_new_object = 0;
292    }
293    else
294    {
295      Py_INCREF(array_descr(ary));
296      result = (PyArrayObject*) PyArray_FromArray(ary,
297                                                  array_descr(ary),
298                                                  NPY_ARRAY_F_CONTIGUOUS);
299      *is_new_object = 1;
300    }
301    return result;
302  }
303
304  /* Convert a given PyObject to a contiguous PyArrayObject of the
305   * specified type.  If the input object is not a contiguous
306   * PyArrayObject, a new one will be created and the new object flag
307   * will be set.
308   */
309  PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
310                                                          int       typecode,
311                                                          int*      is_new_object)
312  {
313    int is_new1 = 0;
314    int is_new2 = 0;
315    PyArrayObject* ary2;
316    PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
317                                                        typecode,
318                                                        &is_new1);
319    if (ary1)
320    {
321      ary2 = make_contiguous(ary1, &is_new2, 0, 0);
322      if ( is_new1 && is_new2)
323      {
324        Py_DECREF(ary1);
325      }
326      ary1 = ary2;
327    }
328    *is_new_object = is_new1 || is_new2;
329    return ary1;
330  }
331
332  /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
333   * specified type.  If the input object is not a Fortran-ordered
334   * PyArrayObject, a new one will be created and the new object flag
335   * will be set.
336   */
337  PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
338                                                       int       typecode,
339                                                       int*      is_new_object)
340  {
341    int is_new1 = 0;
342    int is_new2 = 0;
343    PyArrayObject* ary2;
344    PyArrayObject* ary1 = obj_to_array_allow_conversion(input,
345                                                        typecode,
346                                                        &is_new1);
347    if (ary1)
348    {
349      ary2 = make_fortran(ary1, &is_new2);
350      if (is_new1 && is_new2)
351      {
352        Py_DECREF(ary1);
353      }
354      ary1 = ary2;
355    }
356    *is_new_object = is_new1 || is_new2;
357    return ary1;
358  }
359} /* end fragment */
360
361/**********************************************************************/
362
363%fragment("NumPy_Array_Requirements",
364          "header",
365          fragment="NumPy_Backward_Compatibility",
366          fragment="NumPy_Macros")
367{
368  /* Test whether a python object is contiguous.  If array is
369   * contiguous, return 1.  Otherwise, set the python error string and
370   * return 0.
371   */
372  int require_contiguous(PyArrayObject* ary)
373  {
374    int contiguous = 1;
375    if (!array_is_contiguous(ary))
376    {
377      PyErr_SetString(PyExc_TypeError,
378                      "Array must be contiguous.  A non-contiguous array was given");
379      contiguous = 0;
380    }
381    return contiguous;
382  }
383
384  /* Test whether a python object is (C_ or F_) contiguous.  If array is
385   * contiguous, return 1.  Otherwise, set the python error string and
386   * return 0.
387   */
388  int require_c_or_f_contiguous(PyArrayObject* ary)
389  {
390    int contiguous = 1;
391    if (!(array_is_contiguous(ary) || array_is_fortran(ary)))
392    {
393      PyErr_SetString(PyExc_TypeError,
394                      "Array must be contiguous (C_ or F_).  A non-contiguous array was given");
395      contiguous = 0;
396    }
397    return contiguous;
398  }
399
400  /* Require that a numpy array is not byte-swapped.  If the array is
401   * not byte-swapped, return 1.  Otherwise, set the python error string
402   * and return 0.
403   */
404  int require_native(PyArrayObject* ary)
405  {
406    int native = 1;
407    if (!array_is_native(ary))
408    {
409      PyErr_SetString(PyExc_TypeError,
410                      "Array must have native byteorder.  "
411                      "A byte-swapped array was given");
412      native = 0;
413    }
414    return native;
415  }
416
417  /* Require the given PyArrayObject to have a specified number of
418   * dimensions.  If the array has the specified number of dimensions,
419   * return 1.  Otherwise, set the python error string and return 0.
420   */
421  int require_dimensions(PyArrayObject* ary,
422                         int            exact_dimensions)
423  {
424    int success = 1;
425    if (array_numdims(ary) != exact_dimensions)
426    {
427      PyErr_Format(PyExc_TypeError,
428                   "Array must have %d dimensions.  Given array has %d dimensions",
429                   exact_dimensions,
430                   array_numdims(ary));
431      success = 0;
432    }
433    return success;
434  }
435
436  /* Require the given PyArrayObject to have one of a list of specified
437   * number of dimensions.  If the array has one of the specified number
438   * of dimensions, return 1.  Otherwise, set the python error string
439   * and return 0.
440   */
441  int require_dimensions_n(PyArrayObject* ary,
442                           int*           exact_dimensions,
443                           int            n)
444  {
445    int success = 0;
446    int i;
447    char dims_str[255] = "";
448    char s[255];
449    for (i = 0; i < n && !success; i++)
450    {
451      if (array_numdims(ary) == exact_dimensions[i])
452      {
453        success = 1;
454      }
455    }
456    if (!success)
457    {
458      for (i = 0; i < n-1; i++)
459      {
460        sprintf(s, "%d, ", exact_dimensions[i]);
461        strcat(dims_str,s);
462      }
463      sprintf(s, " or %d", exact_dimensions[n-1]);
464      strcat(dims_str,s);
465      PyErr_Format(PyExc_TypeError,
466                   "Array must have %s dimensions.  Given array has %d dimensions",
467                   dims_str,
468                   array_numdims(ary));
469    }
470    return success;
471  }
472
473  /* Require the given PyArrayObject to have a specified shape.  If the
474   * array has the specified shape, return 1.  Otherwise, set the python
475   * error string and return 0.
476   */
477  int require_size(PyArrayObject* ary,
478                   npy_intp*      size,
479                   int            n)
480  {
481    int i;
482    int success = 1;
483    int len;
484    char desired_dims[255] = "[";
485    char s[255];
486    char actual_dims[255] = "[";
487    for(i=0; i < n;i++)
488    {
489      if (size[i] != -1 &&  size[i] != array_size(ary,i))
490      {
491        success = 0;
492      }
493    }
494    if (!success)
495    {
496      for (i = 0; i < n; i++)
497      {
498        if (size[i] == -1)
499        {
500          sprintf(s, "*,");
501        }
502        else
503        {
504          sprintf(s, "%ld,", (long int)size[i]);
505        }
506        strcat(desired_dims,s);
507      }
508      len = strlen(desired_dims);
509      desired_dims[len-1] = ']';
510      for (i = 0; i < n; i++)
511      {
512        sprintf(s, "%ld,", (long int)array_size(ary,i));
513        strcat(actual_dims,s);
514      }
515      len = strlen(actual_dims);
516      actual_dims[len-1] = ']';
517      PyErr_Format(PyExc_TypeError,
518                   "Array must have shape of %s.  Given array has shape of %s",
519                   desired_dims,
520                   actual_dims);
521    }
522    return success;
523  }
524
525  /* Require the given PyArrayObject to to be Fortran ordered.  If the
526   * the PyArrayObject is already Fortran ordered, do nothing.  Else,
527   * set the Fortran ordering flag and recompute the strides.
528   */
529  int require_fortran(PyArrayObject* ary)
530  {
531    int success = 1;
532    int nd = array_numdims(ary);
533    int i;
534    npy_intp * strides = array_strides(ary);
535    if (array_is_fortran(ary)) return success;
536    /* Set the Fortran ordered flag */
537    array_enableflags(ary,NPY_ARRAY_FARRAY);
538    /* Recompute the strides */
539    strides[0] = strides[nd-1];
540    for (i=1; i < nd; ++i)
541      strides[i] = strides[i-1] * array_size(ary,i-1);
542    return success;
543  }
544}
545
546/* Combine all NumPy fragments into one for convenience */
547%fragment("NumPy_Fragments",
548          "header",
549          fragment="NumPy_Backward_Compatibility",
550          fragment="NumPy_Macros",
551          fragment="NumPy_Utilities",
552          fragment="NumPy_Object_to_Array",
553          fragment="NumPy_Array_Requirements")
554{
555}
556
557/* End John Hunter translation (with modifications by Bill Spotz)
558 */
559
560/* %numpy_typemaps() macro
561 *
562 * This macro defines a family of 75 typemaps that allow C arguments
563 * of the form
564 *
565 *    1. (DATA_TYPE IN_ARRAY1[ANY])
566 *    2. (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
567 *    3. (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
568 *
569 *    4. (DATA_TYPE IN_ARRAY2[ANY][ANY])
570 *    5. (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
571 *    6. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
572 *    7. (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
573 *    8. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
574 *
575 *    9. (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
576 *   10. (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
577 *   11. (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
578 *   12. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
579 *   13. (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
580 *   14. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
581 *
582 *   15. (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
583 *   16. (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
584 *   17. (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
585 *   18. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
586 *   19. (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
587 *   20. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
588 *
589 *   21. (DATA_TYPE INPLACE_ARRAY1[ANY])
590 *   22. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
591 *   23. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
592 *
593 *   24. (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
594 *   25. (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
595 *   26. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
596 *   27. (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
597 *   28. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
598 *
599 *   29. (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
600 *   30. (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
601 *   31. (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
602 *   32. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
603 *   33. (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
604 *   34. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
605 *
606 *   35. (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
607 *   36. (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
608 *   37. (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
609 *   38. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
610 *   39. (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
611 *   40. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
612 *
613 *   41. (DATA_TYPE ARGOUT_ARRAY1[ANY])
614 *   42. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
615 *   43. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
616 *
617 *   44. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
618 *
619 *   45. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
620 *
621 *   46. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
622 *
623 *   47. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
624 *   48. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
625 *
626 *   49. (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
627 *   50. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
628 *   51. (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
629 *   52. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
630 *
631 *   53. (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
632 *   54. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
633 *   55. (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
634 *   56. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
635 *
636 *   57. (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
637 *   58. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
638 *   59. (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
639 *   60. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
640 *
641 *   61. (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
642 *   62. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
643 *
644 *   63. (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
645 *   64. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
646 *   65. (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
647 *   66. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
648 *
649 *   67. (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
650 *   68. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
651 *   69. (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
652 *   70. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
653 *
654 *   71. (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
655 *   72. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
656 *   73. (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
657 *   74. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
658 *
659 *   75. (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT)
660 *
661 * where "DATA_TYPE" is any type supported by the NumPy module, and
662 * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
663 * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
664 * that the "FARRAY" typemaps expect Fortran ordering of
665 * multidimensional arrays.  In python, the dimensions will not need
666 * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
667 * typemaps).  The IN_ARRAYs can be a numpy array or any sequence that
668 * can be converted to a numpy array of the specified type.  The
669 * INPLACE_ARRAYs must be numpy arrays of the appropriate type.  The
670 * ARGOUT_ARRAYs will be returned as new numpy arrays of the
671 * appropriate type.
672 *
673 * These typemaps can be applied to existing functions using the
674 * %apply directive.  For example:
675 *
676 *     %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
677 *     double prod(double* series, int length);
678 *
679 *     %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
680 *           {(int rows, int cols, double* matrix        )};
681 *     void floor(int rows, int cols, double* matrix, double f);
682 *
683 *     %apply (double IN_ARRAY3[ANY][ANY][ANY])
684 *           {(double tensor[2][2][2]         )};
685 *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
686 *           {(double low[2][2][2]                )};
687 *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
688 *           {(double upp[2][2][2]                )};
689 *     void luSplit(double tensor[2][2][2],
690 *                  double low[2][2][2],
691 *                  double upp[2][2][2]    );
692 *
693 * or directly with
694 *
695 *     double prod(double* IN_ARRAY1, int DIM1);
696 *
697 *     void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
698 *
699 *     void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
700 *                  double ARGOUT_ARRAY3[ANY][ANY][ANY],
701 *                  double ARGOUT_ARRAY3[ANY][ANY][ANY]);
702 */
703
704%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
705
706/************************/
707/* Input Array Typemaps */
708/************************/
709
710/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
711 */
712%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
713           fragment="NumPy_Macros")
714  (DATA_TYPE IN_ARRAY1[ANY])
715{
716  $1 = is_array($input) || PySequence_Check($input);
717}
718%typemap(in,
719         fragment="NumPy_Fragments")
720  (DATA_TYPE IN_ARRAY1[ANY])
721  (PyArrayObject* array=NULL, int is_new_object=0)
722{
723  npy_intp size[1] = { $1_dim0 };
724  array = obj_to_array_contiguous_allow_conversion($input,
725                                                   DATA_TYPECODE,
726                                                   &is_new_object);
727  if (!array || !require_dimensions(array, 1) ||
728      !require_size(array, size, 1)) SWIG_fail;
729  $1 = ($1_ltype) array_data(array);
730}
731%typemap(freearg)
732  (DATA_TYPE IN_ARRAY1[ANY])
733{
734  if (is_new_object$argnum && array$argnum)
735    { Py_DECREF(array$argnum); }
736}
737
738/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
739 */
740%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
741           fragment="NumPy_Macros")
742  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
743{
744  $1 = is_array($input) || PySequence_Check($input);
745}
746%typemap(in,
747         fragment="NumPy_Fragments")
748  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
749  (PyArrayObject* array=NULL, int is_new_object=0)
750{
751  npy_intp size[1] = { -1 };
752  array = obj_to_array_contiguous_allow_conversion($input,
753                                                   DATA_TYPECODE,
754                                                   &is_new_object);
755  if (!array || !require_dimensions(array, 1) ||
756      !require_size(array, size, 1)) SWIG_fail;
757  $1 = (DATA_TYPE*) array_data(array);
758  $2 = (DIM_TYPE) array_size(array,0);
759}
760%typemap(freearg)
761  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
762{
763  if (is_new_object$argnum && array$argnum)
764    { Py_DECREF(array$argnum); }
765}
766
767/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
768 */
769%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
770           fragment="NumPy_Macros")
771  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
772{
773  $1 = is_array($input) || PySequence_Check($input);
774}
775%typemap(in,
776         fragment="NumPy_Fragments")
777  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
778  (PyArrayObject* array=NULL, int is_new_object=0)
779{
780  npy_intp size[1] = {-1};
781  array = obj_to_array_contiguous_allow_conversion($input,
782                                                   DATA_TYPECODE,
783                                                   &is_new_object);
784  if (!array || !require_dimensions(array, 1) ||
785      !require_size(array, size, 1)) SWIG_fail;
786  $1 = (DIM_TYPE) array_size(array,0);
787  $2 = (DATA_TYPE*) array_data(array);
788}
789%typemap(freearg)
790  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
791{
792  if (is_new_object$argnum && array$argnum)
793    { Py_DECREF(array$argnum); }
794}
795
796/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
797 */
798%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
799           fragment="NumPy_Macros")
800  (DATA_TYPE IN_ARRAY2[ANY][ANY])
801{
802  $1 = is_array($input) || PySequence_Check($input);
803}
804%typemap(in,
805         fragment="NumPy_Fragments")
806  (DATA_TYPE IN_ARRAY2[ANY][ANY])
807  (PyArrayObject* array=NULL, int is_new_object=0)
808{
809  npy_intp size[2] = { $1_dim0, $1_dim1 };
810  array = obj_to_array_contiguous_allow_conversion($input,
811                                                   DATA_TYPECODE,
812                                                   &is_new_object);
813  if (!array || !require_dimensions(array, 2) ||
814      !require_size(array, size, 2)) SWIG_fail;
815  $1 = ($1_ltype) array_data(array);
816}
817%typemap(freearg)
818  (DATA_TYPE IN_ARRAY2[ANY][ANY])
819{
820  if (is_new_object$argnum && array$argnum)
821    { Py_DECREF(array$argnum); }
822}
823
824/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
825 */
826%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
827           fragment="NumPy_Macros")
828  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
829{
830  $1 = is_array($input) || PySequence_Check($input);
831}
832%typemap(in,
833         fragment="NumPy_Fragments")
834  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
835  (PyArrayObject* array=NULL, int is_new_object=0)
836{
837  npy_intp size[2] = { -1, -1 };
838  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
839                                                   &is_new_object);
840  if (!array || !require_dimensions(array, 2) ||
841      !require_size(array, size, 2)) SWIG_fail;
842  $1 = (DATA_TYPE*) array_data(array);
843  $2 = (DIM_TYPE) array_size(array,0);
844  $3 = (DIM_TYPE) array_size(array,1);
845}
846%typemap(freearg)
847  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
848{
849  if (is_new_object$argnum && array$argnum)
850    { Py_DECREF(array$argnum); }
851}
852
853/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
854 */
855%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
856           fragment="NumPy_Macros")
857  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
858{
859  $1 = is_array($input) || PySequence_Check($input);
860}
861%typemap(in,
862         fragment="NumPy_Fragments")
863  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
864  (PyArrayObject* array=NULL, int is_new_object=0)
865{
866  npy_intp size[2] = { -1, -1 };
867  array = obj_to_array_contiguous_allow_conversion($input,
868                                                   DATA_TYPECODE,
869                                                   &is_new_object);
870  if (!array || !require_dimensions(array, 2) ||
871      !require_size(array, size, 2)) SWIG_fail;
872  $1 = (DIM_TYPE) array_size(array,0);
873  $2 = (DIM_TYPE) array_size(array,1);
874  $3 = (DATA_TYPE*) array_data(array);
875}
876%typemap(freearg)
877  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
878{
879  if (is_new_object$argnum && array$argnum)
880    { Py_DECREF(array$argnum); }
881}
882
883/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
884 */
885%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
886           fragment="NumPy_Macros")
887  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
888{
889  $1 = is_array($input) || PySequence_Check($input);
890}
891%typemap(in,
892         fragment="NumPy_Fragments")
893  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
894  (PyArrayObject* array=NULL, int is_new_object=0)
895{
896  npy_intp size[2] = { -1, -1 };
897  array = obj_to_array_fortran_allow_conversion($input,
898                                                DATA_TYPECODE,
899                                                &is_new_object);
900  if (!array || !require_dimensions(array, 2) ||
901      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
902  $1 = (DATA_TYPE*) array_data(array);
903  $2 = (DIM_TYPE) array_size(array,0);
904  $3 = (DIM_TYPE) array_size(array,1);
905}
906%typemap(freearg)
907  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
908{
909  if (is_new_object$argnum && array$argnum)
910    { Py_DECREF(array$argnum); }
911}
912
913/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
914 */
915%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
916           fragment="NumPy_Macros")
917  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
918{
919  $1 = is_array($input) || PySequence_Check($input);
920}
921%typemap(in,
922         fragment="NumPy_Fragments")
923  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
924  (PyArrayObject* array=NULL, int is_new_object=0)
925{
926  npy_intp size[2] = { -1, -1 };
927  array = obj_to_array_fortran_allow_conversion($input,
928                                                   DATA_TYPECODE,
929                                                   &is_new_object);
930  if (!array || !require_dimensions(array, 2) ||
931      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
932  $1 = (DIM_TYPE) array_size(array,0);
933  $2 = (DIM_TYPE) array_size(array,1);
934  $3 = (DATA_TYPE*) array_data(array);
935}
936%typemap(freearg)
937  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
938{
939  if (is_new_object$argnum && array$argnum)
940    { Py_DECREF(array$argnum); }
941}
942
943/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
944 */
945%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
946           fragment="NumPy_Macros")
947  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
948{
949  $1 = is_array($input) || PySequence_Check($input);
950}
951%typemap(in,
952         fragment="NumPy_Fragments")
953  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
954  (PyArrayObject* array=NULL, int is_new_object=0)
955{
956  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
957  array = obj_to_array_contiguous_allow_conversion($input,
958                                                   DATA_TYPECODE,
959                                                   &is_new_object);
960  if (!array || !require_dimensions(array, 3) ||
961      !require_size(array, size, 3)) SWIG_fail;
962  $1 = ($1_ltype) array_data(array);
963}
964%typemap(freearg)
965  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
966{
967  if (is_new_object$argnum && array$argnum)
968    { Py_DECREF(array$argnum); }
969}
970
971/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
972 *                    DIM_TYPE DIM3)
973 */
974%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
975           fragment="NumPy_Macros")
976  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
977{
978  $1 = is_array($input) || PySequence_Check($input);
979}
980%typemap(in,
981         fragment="NumPy_Fragments")
982  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
983  (PyArrayObject* array=NULL, int is_new_object=0)
984{
985  npy_intp size[3] = { -1, -1, -1 };
986  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
987                                                   &is_new_object);
988  if (!array || !require_dimensions(array, 3) ||
989      !require_size(array, size, 3)) SWIG_fail;
990  $1 = (DATA_TYPE*) array_data(array);
991  $2 = (DIM_TYPE) array_size(array,0);
992  $3 = (DIM_TYPE) array_size(array,1);
993  $4 = (DIM_TYPE) array_size(array,2);
994}
995%typemap(freearg)
996  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
997{
998  if (is_new_object$argnum && array$argnum)
999    { Py_DECREF(array$argnum); }
1000}
1001
1002/* Typemap suite for (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1003 *                    DIM_TYPE DIM3)
1004 */
1005%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1006           fragment="NumPy_Macros")
1007  (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1008{
1009  /* for now, only concerned with lists */
1010  $1 = PySequence_Check($input);
1011}
1012%typemap(in,
1013         fragment="NumPy_Fragments")
1014  (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1015  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL)
1016{
1017  npy_intp size[2] = { -1, -1 };
1018  PyArrayObject* temp_array;
1019  Py_ssize_t i;
1020  int is_new_object;
1021
1022  /* length of the list */
1023  $2 = PyList_Size($input);
1024
1025  /* the arrays */
1026  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
1027  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
1028  is_new_object_array = (int *)calloc($2,sizeof(int));
1029
1030  if (array == NULL || object_array == NULL || is_new_object_array == NULL)
1031  {
1032    SWIG_fail;
1033  }
1034
1035  for (i=0; i<$2; i++)
1036  {
1037    temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object);
1038
1039    /* the new array must be stored so that it can be destroyed in freearg */
1040    object_array[i] = temp_array;
1041    is_new_object_array[i] = is_new_object;
1042
1043    if (!temp_array || !require_dimensions(temp_array, 2)) SWIG_fail;
1044
1045    /* store the size of the first array in the list, then use that for comparison. */
1046    if (i == 0)
1047    {
1048      size[0] = array_size(temp_array,0);
1049      size[1] = array_size(temp_array,1);
1050    }
1051
1052    if (!require_size(temp_array, size, 2)) SWIG_fail;
1053
1054    array[i] = (DATA_TYPE*) array_data(temp_array);
1055  }
1056
1057  $1 = (DATA_TYPE**) array;
1058  $3 = (DIM_TYPE) size[0];
1059  $4 = (DIM_TYPE) size[1];
1060}
1061%typemap(freearg)
1062  (DATA_TYPE** IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1063{
1064  Py_ssize_t i;
1065
1066  if (array$argnum!=NULL) free(array$argnum);
1067
1068  /*freeing the individual arrays if needed */
1069  if (object_array$argnum!=NULL)
1070  {
1071    if (is_new_object_array$argnum!=NULL)
1072    {
1073      for (i=0; i<$2; i++)
1074      {
1075        if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i])
1076        { Py_DECREF(object_array$argnum[i]); }
1077      }
1078      free(is_new_object_array$argnum);
1079    }
1080    free(object_array$argnum);
1081  }
1082}
1083
1084/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1085 *                    DATA_TYPE* IN_ARRAY3)
1086 */
1087%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1088           fragment="NumPy_Macros")
1089  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
1090{
1091  $1 = is_array($input) || PySequence_Check($input);
1092}
1093%typemap(in,
1094         fragment="NumPy_Fragments")
1095  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
1096  (PyArrayObject* array=NULL, int is_new_object=0)
1097{
1098  npy_intp size[3] = { -1, -1, -1 };
1099  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1100                                                   &is_new_object);
1101  if (!array || !require_dimensions(array, 3) ||
1102      !require_size(array, size, 3)) SWIG_fail;
1103  $1 = (DIM_TYPE) array_size(array,0);
1104  $2 = (DIM_TYPE) array_size(array,1);
1105  $3 = (DIM_TYPE) array_size(array,2);
1106  $4 = (DATA_TYPE*) array_data(array);
1107}
1108%typemap(freearg)
1109  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
1110{
1111  if (is_new_object$argnum && array$argnum)
1112    { Py_DECREF(array$argnum); }
1113}
1114
1115/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1116 *                    DIM_TYPE DIM3)
1117 */
1118%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1119           fragment="NumPy_Macros")
1120  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1121{
1122  $1 = is_array($input) || PySequence_Check($input);
1123}
1124%typemap(in,
1125         fragment="NumPy_Fragments")
1126  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1127  (PyArrayObject* array=NULL, int is_new_object=0)
1128{
1129  npy_intp size[3] = { -1, -1, -1 };
1130  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
1131                                                &is_new_object);
1132  if (!array || !require_dimensions(array, 3) ||
1133      !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
1134  $1 = (DATA_TYPE*) array_data(array);
1135  $2 = (DIM_TYPE) array_size(array,0);
1136  $3 = (DIM_TYPE) array_size(array,1);
1137  $4 = (DIM_TYPE) array_size(array,2);
1138}
1139%typemap(freearg)
1140  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1141{
1142  if (is_new_object$argnum && array$argnum)
1143    { Py_DECREF(array$argnum); }
1144}
1145
1146/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1147 *                    DATA_TYPE* IN_FARRAY3)
1148 */
1149%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1150           fragment="NumPy_Macros")
1151  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
1152{
1153  $1 = is_array($input) || PySequence_Check($input);
1154}
1155%typemap(in,
1156         fragment="NumPy_Fragments")
1157  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
1158  (PyArrayObject* array=NULL, int is_new_object=0)
1159{
1160  npy_intp size[3] = { -1, -1, -1 };
1161  array = obj_to_array_fortran_allow_conversion($input,
1162                                                   DATA_TYPECODE,
1163                                                   &is_new_object);
1164  if (!array || !require_dimensions(array, 3) ||
1165      !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
1166  $1 = (DIM_TYPE) array_size(array,0);
1167  $2 = (DIM_TYPE) array_size(array,1);
1168  $3 = (DIM_TYPE) array_size(array,2);
1169  $4 = (DATA_TYPE*) array_data(array);
1170}
1171%typemap(freearg)
1172  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
1173{
1174  if (is_new_object$argnum && array$argnum)
1175    { Py_DECREF(array$argnum); }
1176}
1177
1178/* Typemap suite for (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1179 */
1180%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1181           fragment="NumPy_Macros")
1182  (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1183{
1184  $1 = is_array($input) || PySequence_Check($input);
1185}
1186%typemap(in,
1187         fragment="NumPy_Fragments")
1188  (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1189  (PyArrayObject* array=NULL, int is_new_object=0)
1190{
1191  npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3};
1192  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1193                                                   &is_new_object);
1194  if (!array || !require_dimensions(array, 4) ||
1195      !require_size(array, size, 4)) SWIG_fail;
1196  $1 = ($1_ltype) array_data(array);
1197}
1198%typemap(freearg)
1199  (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1200{
1201  if (is_new_object$argnum && array$argnum)
1202    { Py_DECREF(array$argnum); }
1203}
1204
1205/* Typemap suite for (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1206 *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1207 */
1208%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1209           fragment="NumPy_Macros")
1210  (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1211{
1212  $1 = is_array($input) || PySequence_Check($input);
1213}
1214%typemap(in,
1215         fragment="NumPy_Fragments")
1216  (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1217  (PyArrayObject* array=NULL, int is_new_object=0)
1218{
1219  npy_intp size[4] = { -1, -1, -1, -1 };
1220  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1221                                                   &is_new_object);
1222  if (!array || !require_dimensions(array, 4) ||
1223      !require_size(array, size, 4)) SWIG_fail;
1224  $1 = (DATA_TYPE*) array_data(array);
1225  $2 = (DIM_TYPE) array_size(array,0);
1226  $3 = (DIM_TYPE) array_size(array,1);
1227  $4 = (DIM_TYPE) array_size(array,2);
1228  $5 = (DIM_TYPE) array_size(array,3);
1229}
1230%typemap(freearg)
1231  (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1232{
1233  if (is_new_object$argnum && array$argnum)
1234    { Py_DECREF(array$argnum); }
1235}
1236
1237/* Typemap suite for (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1238 *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1239 */
1240%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1241           fragment="NumPy_Macros")
1242  (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1243{
1244  /* for now, only concerned with lists */
1245  $1 = PySequence_Check($input);
1246}
1247%typemap(in,
1248         fragment="NumPy_Fragments")
1249  (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1250  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL, int* is_new_object_array=NULL)
1251{
1252  npy_intp size[3] = { -1, -1, -1 };
1253  PyArrayObject* temp_array;
1254  Py_ssize_t i;
1255  int is_new_object;
1256
1257  /* length of the list */
1258  $2 = PyList_Size($input);
1259
1260  /* the arrays */
1261  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
1262  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
1263  is_new_object_array = (int *)calloc($2,sizeof(int));
1264
1265  if (array == NULL || object_array == NULL || is_new_object_array == NULL)
1266  {
1267    SWIG_fail;
1268  }
1269
1270  for (i=0; i<$2; i++)
1271  {
1272    temp_array = obj_to_array_contiguous_allow_conversion(PySequence_GetItem($input,i), DATA_TYPECODE, &is_new_object);
1273
1274    /* the new array must be stored so that it can be destroyed in freearg */
1275    object_array[i] = temp_array;
1276    is_new_object_array[i] = is_new_object;
1277
1278    if (!temp_array || !require_dimensions(temp_array, 3)) SWIG_fail;
1279
1280    /* store the size of the first array in the list, then use that for comparison. */
1281    if (i == 0)
1282    {
1283      size[0] = array_size(temp_array,0);
1284      size[1] = array_size(temp_array,1);
1285      size[2] = array_size(temp_array,2);
1286    }
1287
1288    if (!require_size(temp_array, size, 3)) SWIG_fail;
1289
1290    array[i] = (DATA_TYPE*) array_data(temp_array);
1291  }
1292
1293  $1 = (DATA_TYPE**) array;
1294  $3 = (DIM_TYPE) size[0];
1295  $4 = (DIM_TYPE) size[1];
1296  $5 = (DIM_TYPE) size[2];
1297}
1298%typemap(freearg)
1299  (DATA_TYPE** IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1300{
1301  Py_ssize_t i;
1302
1303  if (array$argnum!=NULL) free(array$argnum);
1304
1305  /*freeing the individual arrays if needed */
1306  if (object_array$argnum!=NULL)
1307  {
1308    if (is_new_object_array$argnum!=NULL)
1309    {
1310      for (i=0; i<$2; i++)
1311      {
1312        if (object_array$argnum[i] != NULL && is_new_object_array$argnum[i])
1313        { Py_DECREF(object_array$argnum[i]); }
1314      }
1315      free(is_new_object_array$argnum);
1316    }
1317    free(object_array$argnum);
1318  }
1319}
1320
1321/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
1322 *                    DATA_TYPE* IN_ARRAY4)
1323 */
1324%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1325           fragment="NumPy_Macros")
1326  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
1327{
1328  $1 = is_array($input) || PySequence_Check($input);
1329}
1330%typemap(in,
1331         fragment="NumPy_Fragments")
1332  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
1333  (PyArrayObject* array=NULL, int is_new_object=0)
1334{
1335  npy_intp size[4] = { -1, -1, -1 , -1};
1336  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1337                                                   &is_new_object);
1338  if (!array || !require_dimensions(array, 4) ||
1339      !require_size(array, size, 4)) SWIG_fail;
1340  $1 = (DIM_TYPE) array_size(array,0);
1341  $2 = (DIM_TYPE) array_size(array,1);
1342  $3 = (DIM_TYPE) array_size(array,2);
1343  $4 = (DIM_TYPE) array_size(array,3);
1344  $5 = (DATA_TYPE*) array_data(array);
1345}
1346%typemap(freearg)
1347  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
1348{
1349  if (is_new_object$argnum && array$argnum)
1350    { Py_DECREF(array$argnum); }
1351}
1352
1353/* Typemap suite for (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1354 *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1355 */
1356%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1357           fragment="NumPy_Macros")
1358  (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1359{
1360  $1 = is_array($input) || PySequence_Check($input);
1361}
1362%typemap(in,
1363         fragment="NumPy_Fragments")
1364  (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1365  (PyArrayObject* array=NULL, int is_new_object=0)
1366{
1367  npy_intp size[4] = { -1, -1, -1, -1 };
1368  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
1369                                                &is_new_object);
1370  if (!array || !require_dimensions(array, 4) ||
1371      !require_size(array, size, 4) | !require_fortran(array)) SWIG_fail;
1372  $1 = (DATA_TYPE*) array_data(array);
1373  $2 = (DIM_TYPE) array_size(array,0);
1374  $3 = (DIM_TYPE) array_size(array,1);
1375  $4 = (DIM_TYPE) array_size(array,2);
1376  $5 = (DIM_TYPE) array_size(array,3);
1377}
1378%typemap(freearg)
1379  (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1380{
1381  if (is_new_object$argnum && array$argnum)
1382    { Py_DECREF(array$argnum); }
1383}
1384
1385/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
1386 *                    DATA_TYPE* IN_FARRAY4)
1387 */
1388%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1389           fragment="NumPy_Macros")
1390  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
1391{
1392  $1 = is_array($input) || PySequence_Check($input);
1393}
1394%typemap(in,
1395         fragment="NumPy_Fragments")
1396  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
1397  (PyArrayObject* array=NULL, int is_new_object=0)
1398{
1399  npy_intp size[4] = { -1, -1, -1 , -1 };
1400  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
1401                                                   &is_new_object);
1402  if (!array || !require_dimensions(array, 4) ||
1403      !require_size(array, size, 4) || !require_fortran(array)) SWIG_fail;
1404  $1 = (DIM_TYPE) array_size(array,0);
1405  $2 = (DIM_TYPE) array_size(array,1);
1406  $3 = (DIM_TYPE) array_size(array,2);
1407  $4 = (DIM_TYPE) array_size(array,3);
1408  $5 = (DATA_TYPE*) array_data(array);
1409}
1410%typemap(freearg)
1411  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
1412{
1413  if (is_new_object$argnum && array$argnum)
1414    { Py_DECREF(array$argnum); }
1415}
1416
1417/***************************/
1418/* In-Place Array Typemaps */
1419/***************************/
1420
1421/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
1422 */
1423%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1424           fragment="NumPy_Macros")
1425  (DATA_TYPE INPLACE_ARRAY1[ANY])
1426{
1427  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1428                                                 DATA_TYPECODE);
1429}
1430%typemap(in,
1431         fragment="NumPy_Fragments")
1432  (DATA_TYPE INPLACE_ARRAY1[ANY])
1433  (PyArrayObject* array=NULL)
1434{
1435  npy_intp size[1] = { $1_dim0 };
1436  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1437  if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
1438      !require_contiguous(array) || !require_native(array)) SWIG_fail;
1439  $1 = ($1_ltype) array_data(array);
1440}
1441
1442/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
1443 */
1444%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1445           fragment="NumPy_Macros")
1446  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
1447{
1448  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1449                                                 DATA_TYPECODE);
1450}
1451%typemap(in,
1452         fragment="NumPy_Fragments")
1453  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
1454  (PyArrayObject* array=NULL, int i=1)
1455{
1456  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1457  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
1458      || !require_native(array)) SWIG_fail;
1459  $1 = (DATA_TYPE*) array_data(array);
1460  $2 = 1;
1461  for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
1462}
1463
1464/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1465 */
1466%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1467           fragment="NumPy_Macros")
1468  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1469{
1470  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1471                                                 DATA_TYPECODE);
1472}
1473%typemap(in,
1474         fragment="NumPy_Fragments")
1475  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1476  (PyArrayObject* array=NULL, int i=0)
1477{
1478  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1479  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
1480      || !require_native(array)) SWIG_fail;
1481  $1 = 1;
1482  for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
1483  $2 = (DATA_TYPE*) array_data(array);
1484}
1485
1486/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1487 */
1488%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1489           fragment="NumPy_Macros")
1490  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1491{
1492  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1493                                                 DATA_TYPECODE);
1494}
1495%typemap(in,
1496         fragment="NumPy_Fragments")
1497  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1498  (PyArrayObject* array=NULL)
1499{
1500  npy_intp size[2] = { $1_dim0, $1_dim1 };
1501  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1502  if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
1503      !require_contiguous(array) || !require_native(array)) SWIG_fail;
1504  $1 = ($1_ltype) array_data(array);
1505}
1506
1507/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1508 */
1509%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1510           fragment="NumPy_Macros")
1511  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1512{
1513  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1514                                                 DATA_TYPECODE);
1515}
1516%typemap(in,
1517         fragment="NumPy_Fragments")
1518  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1519  (PyArrayObject* array=NULL)
1520{
1521  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1522  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
1523      || !require_native(array)) SWIG_fail;
1524  $1 = (DATA_TYPE*) array_data(array);
1525  $2 = (DIM_TYPE) array_size(array,0);
1526  $3 = (DIM_TYPE) array_size(array,1);
1527}
1528
1529/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1530 */
1531%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1532           fragment="NumPy_Macros")
1533  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1534{
1535  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1536                                                 DATA_TYPECODE);
1537}
1538%typemap(in,
1539         fragment="NumPy_Fragments")
1540  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1541  (PyArrayObject* array=NULL)
1542{
1543  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1544  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
1545      !require_native(array)) SWIG_fail;
1546  $1 = (DIM_TYPE) array_size(array,0);
1547  $2 = (DIM_TYPE) array_size(array,1);
1548  $3 = (DATA_TYPE*) array_data(array);
1549}
1550
1551/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1552 */
1553%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1554           fragment="NumPy_Macros")
1555  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1556{
1557  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1558                                                 DATA_TYPECODE);
1559}
1560%typemap(in,
1561         fragment="NumPy_Fragments")
1562  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1563  (PyArrayObject* array=NULL)
1564{
1565  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1566  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
1567      || !require_native(array) || !require_fortran(array)) SWIG_fail;
1568  $1 = (DATA_TYPE*) array_data(array);
1569  $2 = (DIM_TYPE) array_size(array,0);
1570  $3 = (DIM_TYPE) array_size(array,1);
1571}
1572
1573/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1574 */
1575%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1576           fragment="NumPy_Macros")
1577  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1578{
1579  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1580                                                 DATA_TYPECODE);
1581}
1582%typemap(in,
1583         fragment="NumPy_Fragments")
1584  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1585  (PyArrayObject* array=NULL)
1586{
1587  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1588  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
1589      !require_native(array) || !require_fortran(array)) SWIG_fail;
1590  $1 = (DIM_TYPE) array_size(array,0);
1591  $2 = (DIM_TYPE) array_size(array,1);
1592  $3 = (DATA_TYPE*) array_data(array);
1593}
1594
1595/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1596 */
1597%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1598           fragment="NumPy_Macros")
1599  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1600{
1601  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1602                                                 DATA_TYPECODE);
1603}
1604%typemap(in,
1605         fragment="NumPy_Fragments")
1606  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1607  (PyArrayObject* array=NULL)
1608{
1609  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
1610  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1611  if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
1612      !require_contiguous(array) || !require_native(array)) SWIG_fail;
1613  $1 = ($1_ltype) array_data(array);
1614}
1615
1616/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1617 *                    DIM_TYPE DIM3)
1618 */
1619%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1620           fragment="NumPy_Macros")
1621  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1622{
1623  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1624                                                 DATA_TYPECODE);
1625}
1626%typemap(in,
1627         fragment="NumPy_Fragments")
1628  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1629  (PyArrayObject* array=NULL)
1630{
1631  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1632  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
1633      !require_native(array)) SWIG_fail;
1634  $1 = (DATA_TYPE*) array_data(array);
1635  $2 = (DIM_TYPE) array_size(array,0);
1636  $3 = (DIM_TYPE) array_size(array,1);
1637  $4 = (DIM_TYPE) array_size(array,2);
1638}
1639
1640/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1641 *                    DIM_TYPE DIM3)
1642 */
1643%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1644           fragment="NumPy_Macros")
1645  (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1646{
1647  $1 = PySequence_Check($input);
1648}
1649%typemap(in,
1650         fragment="NumPy_Fragments")
1651  (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1652  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL)
1653{
1654  npy_intp size[2] = { -1, -1 };
1655  PyArrayObject* temp_array;
1656  Py_ssize_t i;
1657
1658  /* length of the list */
1659  $2 = PyList_Size($input);
1660
1661  /* the arrays */
1662  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
1663  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
1664
1665  if (array == NULL || object_array == NULL)
1666  {
1667    SWIG_fail;
1668  }
1669
1670  for (i=0; i<$2; i++)
1671  {
1672    temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE);
1673
1674    /* the new array must be stored so that it can be destroyed in freearg */
1675    object_array[i] = temp_array;
1676
1677    if ( !temp_array || !require_dimensions(temp_array, 2) ||
1678      !require_contiguous(temp_array) ||
1679      !require_native(temp_array) ||
1680      !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE)
1681    ) SWIG_fail;
1682
1683    /* store the size of the first array in the list, then use that for comparison. */
1684    if (i == 0)
1685    {
1686      size[0] = array_size(temp_array,0);
1687      size[1] = array_size(temp_array,1);
1688    }
1689
1690    if (!require_size(temp_array, size, 2)) SWIG_fail;
1691
1692    array[i] = (DATA_TYPE*) array_data(temp_array);
1693  }
1694
1695  $1 = (DATA_TYPE**) array;
1696  $3 = (DIM_TYPE) size[0];
1697  $4 = (DIM_TYPE) size[1];
1698}
1699%typemap(freearg)
1700  (DATA_TYPE** INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1701{
1702  if (array$argnum!=NULL) free(array$argnum);
1703  if (object_array$argnum!=NULL) free(object_array$argnum);
1704}
1705
1706/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1707 *                    DATA_TYPE* INPLACE_ARRAY3)
1708 */
1709%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1710           fragment="NumPy_Macros")
1711  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
1712{
1713  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1714                                                 DATA_TYPECODE);
1715}
1716%typemap(in,
1717         fragment="NumPy_Fragments")
1718  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
1719  (PyArrayObject* array=NULL)
1720{
1721  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1722  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
1723      || !require_native(array)) SWIG_fail;
1724  $1 = (DIM_TYPE) array_size(array,0);
1725  $2 = (DIM_TYPE) array_size(array,1);
1726  $3 = (DIM_TYPE) array_size(array,2);
1727  $4 = (DATA_TYPE*) array_data(array);
1728}
1729
1730/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1731 *                    DIM_TYPE DIM3)
1732 */
1733%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1734           fragment="NumPy_Macros")
1735  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1736{
1737  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1738                                                 DATA_TYPECODE);
1739}
1740%typemap(in,
1741         fragment="NumPy_Fragments")
1742  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1743  (PyArrayObject* array=NULL)
1744{
1745  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1746  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
1747      !require_native(array) || !require_fortran(array)) SWIG_fail;
1748  $1 = (DATA_TYPE*) array_data(array);
1749  $2 = (DIM_TYPE) array_size(array,0);
1750  $3 = (DIM_TYPE) array_size(array,1);
1751  $4 = (DIM_TYPE) array_size(array,2);
1752}
1753
1754/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1755 *                    DATA_TYPE* INPLACE_FARRAY3)
1756 */
1757%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1758           fragment="NumPy_Macros")
1759  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
1760{
1761  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1762                                                 DATA_TYPECODE);
1763}
1764%typemap(in,
1765         fragment="NumPy_Fragments")
1766  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
1767  (PyArrayObject* array=NULL)
1768{
1769  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1770  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
1771      || !require_native(array) || !require_fortran(array)) SWIG_fail;
1772  $1 = (DIM_TYPE) array_size(array,0);
1773  $2 = (DIM_TYPE) array_size(array,1);
1774  $3 = (DIM_TYPE) array_size(array,2);
1775  $4 = (DATA_TYPE*) array_data(array);
1776}
1777
1778/* Typemap suite for (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
1779 */
1780%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1781           fragment="NumPy_Macros")
1782  (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
1783{
1784  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1785                                                 DATA_TYPECODE);
1786}
1787%typemap(in,
1788         fragment="NumPy_Fragments")
1789  (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
1790  (PyArrayObject* array=NULL)
1791{
1792  npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3 };
1793  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1794  if (!array || !require_dimensions(array,4) || !require_size(array, size, 4) ||
1795      !require_contiguous(array) || !require_native(array)) SWIG_fail;
1796  $1 = ($1_ltype) array_data(array);
1797}
1798
1799/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1800 *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1801 */
1802%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1803           fragment="NumPy_Macros")
1804  (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1805{
1806  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1807                                                 DATA_TYPECODE);
1808}
1809%typemap(in,
1810         fragment="NumPy_Fragments")
1811  (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1812  (PyArrayObject* array=NULL)
1813{
1814  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1815  if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
1816      !require_native(array)) SWIG_fail;
1817  $1 = (DATA_TYPE*) array_data(array);
1818  $2 = (DIM_TYPE) array_size(array,0);
1819  $3 = (DIM_TYPE) array_size(array,1);
1820  $4 = (DIM_TYPE) array_size(array,2);
1821  $5 = (DIM_TYPE) array_size(array,3);
1822}
1823
1824/* Typemap suite for (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1825 *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1826 */
1827%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1828           fragment="NumPy_Macros")
1829  (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1830{
1831  $1 = PySequence_Check($input);
1832}
1833%typemap(in,
1834         fragment="NumPy_Fragments")
1835  (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1836  (DATA_TYPE** array=NULL, PyArrayObject** object_array=NULL)
1837{
1838  npy_intp size[3] = { -1, -1, -1 };
1839  PyArrayObject* temp_array;
1840  Py_ssize_t i;
1841
1842  /* length of the list */
1843  $2 = PyList_Size($input);
1844
1845  /* the arrays */
1846  array = (DATA_TYPE **)malloc($2*sizeof(DATA_TYPE *));
1847  object_array = (PyArrayObject **)calloc($2,sizeof(PyArrayObject *));
1848
1849  if (array == NULL || object_array == NULL)
1850  {
1851    SWIG_fail;
1852  }
1853
1854  for (i=0; i<$2; i++)
1855  {
1856    temp_array = obj_to_array_no_conversion(PySequence_GetItem($input,i), DATA_TYPECODE);
1857
1858    /* the new array must be stored so that it can be destroyed in freearg */
1859    object_array[i] = temp_array;
1860
1861    if ( !temp_array || !require_dimensions(temp_array, 3) ||
1862      !require_contiguous(temp_array) ||
1863      !require_native(temp_array) ||
1864      !PyArray_EquivTypenums(array_type(temp_array), DATA_TYPECODE)
1865    ) SWIG_fail;
1866
1867    /* store the size of the first array in the list, then use that for comparison. */
1868    if (i == 0)
1869    {
1870      size[0] = array_size(temp_array,0);
1871      size[1] = array_size(temp_array,1);
1872      size[2] = array_size(temp_array,2);
1873    }
1874
1875    if (!require_size(temp_array, size, 3)) SWIG_fail;
1876
1877    array[i] = (DATA_TYPE*) array_data(temp_array);
1878  }
1879
1880  $1 = (DATA_TYPE**) array;
1881  $3 = (DIM_TYPE) size[0];
1882  $4 = (DIM_TYPE) size[1];
1883  $5 = (DIM_TYPE) size[2];
1884}
1885%typemap(freearg)
1886  (DATA_TYPE** INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1887{
1888  if (array$argnum!=NULL) free(array$argnum);
1889  if (object_array$argnum!=NULL) free(object_array$argnum);
1890}
1891
1892/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
1893 *                    DATA_TYPE* INPLACE_ARRAY4)
1894 */
1895%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1896           fragment="NumPy_Macros")
1897  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
1898{
1899  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1900                                                 DATA_TYPECODE);
1901}
1902%typemap(in,
1903         fragment="NumPy_Fragments")
1904  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
1905  (PyArrayObject* array=NULL)
1906{
1907  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1908  if (!array || !require_dimensions(array,4) || !require_contiguous(array)
1909      || !require_native(array)) SWIG_fail;
1910  $1 = (DIM_TYPE) array_size(array,0);
1911  $2 = (DIM_TYPE) array_size(array,1);
1912  $3 = (DIM_TYPE) array_size(array,2);
1913  $4 = (DIM_TYPE) array_size(array,3);
1914  $5 = (DATA_TYPE*) array_data(array);
1915}
1916
1917/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1918 *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1919 */
1920%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1921           fragment="NumPy_Macros")
1922  (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1923{
1924  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1925                                                 DATA_TYPECODE);
1926}
1927%typemap(in,
1928         fragment="NumPy_Fragments")
1929  (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1930  (PyArrayObject* array=NULL)
1931{
1932  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1933  if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
1934      !require_native(array) || !require_fortran(array)) SWIG_fail;
1935  $1 = (DATA_TYPE*) array_data(array);
1936  $2 = (DIM_TYPE) array_size(array,0);
1937  $3 = (DIM_TYPE) array_size(array,1);
1938  $4 = (DIM_TYPE) array_size(array,2);
1939  $5 = (DIM_TYPE) array_size(array,3);
1940}
1941
1942/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1943 *                    DATA_TYPE* INPLACE_FARRAY4)
1944 */
1945%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1946           fragment="NumPy_Macros")
1947  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
1948{
1949  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1950                                                 DATA_TYPECODE);
1951}
1952%typemap(in,
1953         fragment="NumPy_Fragments")
1954  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
1955  (PyArrayObject* array=NULL)
1956{
1957  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1958  if (!array || !require_dimensions(array,4) || !require_contiguous(array)
1959      || !require_native(array) || !require_fortran(array)) SWIG_fail;
1960  $1 = (DIM_TYPE) array_size(array,0);
1961  $2 = (DIM_TYPE) array_size(array,1);
1962  $3 = (DIM_TYPE) array_size(array,2);
1963  $4 = (DIM_TYPE) array_size(array,3);
1964  $5 = (DATA_TYPE*) array_data(array);
1965}
1966
1967/*************************/
1968/* Argout Array Typemaps */
1969/*************************/
1970
1971/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
1972 */
1973%typemap(in,numinputs=0,
1974         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1975  (DATA_TYPE ARGOUT_ARRAY1[ANY])
1976  (PyObject* array = NULL)
1977{
1978  npy_intp dims[1] = { $1_dim0 };
1979  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1980  if (!array) SWIG_fail;
1981  $1 = ($1_ltype) array_data(array);
1982}
1983%typemap(argout)
1984  (DATA_TYPE ARGOUT_ARRAY1[ANY])
1985{
1986  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
1987}
1988
1989/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1990 */
1991%typemap(in,numinputs=1,
1992         fragment="NumPy_Fragments")
1993  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1994  (PyObject* array = NULL)
1995{
1996  npy_intp dims[1];
1997  if (!PyInt_Check($input))
1998  {
1999    const char* typestring = pytype_string($input);
2000    PyErr_Format(PyExc_TypeError,
2001                 "Int dimension expected.  '%s' given.",
2002                 typestring);
2003    SWIG_fail;
2004  }
2005  $2 = (DIM_TYPE) PyInt_AsLong($input);
2006  dims[0] = (npy_intp) $2;
2007  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
2008  if (!array) SWIG_fail;
2009  $1 = (DATA_TYPE*) array_data(array);
2010}
2011%typemap(argout)
2012  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
2013{
2014  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
2015}
2016
2017/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
2018 */
2019%typemap(in,numinputs=1,
2020         fragment="NumPy_Fragments")
2021  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
2022  (PyObject* array = NULL)
2023{
2024  npy_intp dims[1];
2025  if (!PyInt_Check($input))
2026  {
2027    const char* typestring = pytype_string($input);
2028    PyErr_Format(PyExc_TypeError,
2029                 "Int dimension expected.  '%s' given.",
2030                 typestring);
2031    SWIG_fail;
2032  }
2033  $1 = (DIM_TYPE) PyInt_AsLong($input);
2034  dims[0] = (npy_intp) $1;
2035  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
2036  if (!array) SWIG_fail;
2037  $2 = (DATA_TYPE*) array_data(array);
2038}
2039%typemap(argout)
2040  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
2041{
2042  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
2043}
2044
2045/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
2046 */
2047%typemap(in,numinputs=0,
2048         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
2049  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
2050  (PyObject* array = NULL)
2051{
2052  npy_intp dims[2] = { $1_dim0, $1_dim1 };
2053  array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
2054  if (!array) SWIG_fail;
2055  $1 = ($1_ltype) array_data(array);
2056}
2057%typemap(argout)
2058  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
2059{
2060  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
2061}
2062
2063/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
2064 */
2065%typemap(in,numinputs=0,
2066         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
2067  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
2068  (PyObject* array = NULL)
2069{
2070  npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
2071  array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
2072  if (!array) SWIG_fail;
2073  $1 = ($1_ltype) array_data(array);
2074}
2075%typemap(argout)
2076  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
2077{
2078  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
2079}
2080
2081/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
2082 */
2083%typemap(in,numinputs=0,
2084         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
2085  (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
2086  (PyObject* array = NULL)
2087{
2088  npy_intp dims[4] = { $1_dim0, $1_dim1, $1_dim2, $1_dim3 };
2089  array = PyArray_SimpleNew(4, dims, DATA_TYPECODE);
2090  if (!array) SWIG_fail;
2091  $1 = ($1_ltype) array_data(array);
2092}
2093%typemap(argout)
2094  (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
2095{
2096  $result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
2097}
2098
2099/*****************************/
2100/* Argoutview Array Typemaps */
2101/*****************************/
2102
2103/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
2104 */
2105%typemap(in,numinputs=0)
2106  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1    )
2107  (DATA_TYPE*  data_temp = NULL , DIM_TYPE  dim_temp)
2108{
2109  $1 = &data_temp;
2110  $2 = &dim_temp;
2111}
2112%typemap(argout,
2113         fragment="NumPy_Backward_Compatibility")
2114  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
2115{
2116  npy_intp dims[1] = { *$2 };
2117  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
2118  PyArrayObject* array = (PyArrayObject*) obj;
2119
2120  if (!array) SWIG_fail;
2121  $result = SWIG_Python_AppendOutput($result,obj);
2122}
2123
2124/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
2125 */
2126%typemap(in,numinputs=0)
2127  (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEW_ARRAY1)
2128  (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp = NULL )
2129{
2130  $1 = &dim_temp;
2131  $2 = &data_temp;
2132}
2133%typemap(argout,
2134         fragment="NumPy_Backward_Compatibility")
2135  (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
2136{
2137  npy_intp dims[1] = { *$1 };
2138  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
2139  PyArrayObject* array = (PyArrayObject*) obj;
2140
2141  if (!array) SWIG_fail;
2142  $result = SWIG_Python_AppendOutput($result,obj);
2143}
2144
2145/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2146 */
2147%typemap(in,numinputs=0)
2148  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
2149  (DATA_TYPE*  data_temp = NULL , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
2150{
2151  $1 = &data_temp;
2152  $2 = &dim1_temp;
2153  $3 = &dim2_temp;
2154}
2155%typemap(argout,
2156         fragment="NumPy_Backward_Compatibility")
2157  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2158{
2159  npy_intp dims[2] = { *$2, *$3 };
2160  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
2161  PyArrayObject* array = (PyArrayObject*) obj;
2162
2163  if (!array) SWIG_fail;
2164  $result = SWIG_Python_AppendOutput($result,obj);
2165}
2166
2167/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
2168 */
2169%typemap(in,numinputs=0)
2170  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_ARRAY2)
2171  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL )
2172{
2173  $1 = &dim1_temp;
2174  $2 = &dim2_temp;
2175  $3 = &data_temp;
2176}
2177%typemap(argout,
2178         fragment="NumPy_Backward_Compatibility")
2179  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
2180{
2181  npy_intp dims[2] = { *$1, *$2 };
2182  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
2183  PyArrayObject* array = (PyArrayObject*) obj;
2184
2185  if (!array) SWIG_fail;
2186  $result = SWIG_Python_AppendOutput($result,obj);
2187}
2188
2189/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2190 */
2191%typemap(in,numinputs=0)
2192  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
2193  (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
2194{
2195  $1 = &data_temp;
2196  $2 = &dim1_temp;
2197  $3 = &dim2_temp;
2198}
2199%typemap(argout,
2200         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2201  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2202{
2203  npy_intp dims[2] = { *$2, *$3 };
2204  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
2205  PyArrayObject* array = (PyArrayObject*) obj;
2206
2207  if (!array || !require_fortran(array)) SWIG_fail;
2208  $result = SWIG_Python_AppendOutput($result,obj);
2209}
2210
2211/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
2212 */
2213%typemap(in,numinputs=0)
2214  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_FARRAY2)
2215  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL  )
2216{
2217  $1 = &dim1_temp;
2218  $2 = &dim2_temp;
2219  $3 = &data_temp;
2220}
2221%typemap(argout,
2222         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2223  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
2224{
2225  npy_intp dims[2] = { *$1, *$2 };
2226  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
2227  PyArrayObject* array = (PyArrayObject*) obj;
2228
2229  if (!array || !require_fortran(array)) SWIG_fail;
2230  $result = SWIG_Python_AppendOutput($result,obj);
2231}
2232
2233/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2234                      DIM_TYPE* DIM3)
2235 */
2236%typemap(in,numinputs=0)
2237  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
2238  (DATA_TYPE* data_temp = NULL  , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
2239{
2240  $1 = &data_temp;
2241  $2 = &dim1_temp;
2242  $3 = &dim2_temp;
2243  $4 = &dim3_temp;
2244}
2245%typemap(argout,
2246         fragment="NumPy_Backward_Compatibility")
2247  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2248{
2249  npy_intp dims[3] = { *$2, *$3, *$4 };
2250  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
2251  PyArrayObject* array = (PyArrayObject*) obj;
2252
2253  if (!array) SWIG_fail;
2254  $result = SWIG_Python_AppendOutput($result,obj);
2255}
2256
2257/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
2258                      DATA_TYPE** ARGOUTVIEW_ARRAY3)
2259 */
2260%typemap(in,numinputs=0)
2261  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
2262  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL)
2263{
2264  $1 = &dim1_temp;
2265  $2 = &dim2_temp;
2266  $3 = &dim3_temp;
2267  $4 = &data_temp;
2268}
2269%typemap(argout,
2270         fragment="NumPy_Backward_Compatibility")
2271  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
2272{
2273  npy_intp dims[3] = { *$1, *$2, *$3 };
2274  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
2275  PyArrayObject* array = (PyArrayObject*) obj;
2276
2277  if (!array) SWIG_fail;
2278  $result = SWIG_Python_AppendOutput($result,obj);
2279}
2280
2281/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2282                      DIM_TYPE* DIM3)
2283 */
2284%typemap(in,numinputs=0)
2285  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
2286  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
2287{
2288  $1 = &data_temp;
2289  $2 = &dim1_temp;
2290  $3 = &dim2_temp;
2291  $4 = &dim3_temp;
2292}
2293%typemap(argout,
2294         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2295  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2296{
2297  npy_intp dims[3] = { *$2, *$3, *$4 };
2298  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
2299  PyArrayObject* array = (PyArrayObject*) obj;
2300
2301  if (!array || !require_fortran(array)) SWIG_fail;
2302  $result = SWIG_Python_AppendOutput($result,obj);
2303}
2304
2305/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
2306                      DATA_TYPE** ARGOUTVIEW_FARRAY3)
2307 */
2308%typemap(in,numinputs=0)
2309  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEW_FARRAY3)
2310  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL   )
2311{
2312  $1 = &dim1_temp;
2313  $2 = &dim2_temp;
2314  $3 = &dim3_temp;
2315  $4 = &data_temp;
2316}
2317%typemap(argout,
2318         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2319  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
2320{
2321  npy_intp dims[3] = { *$1, *$2, *$3 };
2322  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
2323  PyArrayObject* array = (PyArrayObject*) obj;
2324
2325  if (!array || !require_fortran(array)) SWIG_fail;
2326  $result = SWIG_Python_AppendOutput($result,obj);
2327}
2328
2329/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2330                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2331 */
2332%typemap(in,numinputs=0)
2333  (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2334  (DATA_TYPE* data_temp = NULL  , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2335{
2336  $1 = &data_temp;
2337  $2 = &dim1_temp;
2338  $3 = &dim2_temp;
2339  $4 = &dim3_temp;
2340  $5 = &dim4_temp;
2341}
2342%typemap(argout,
2343         fragment="NumPy_Backward_Compatibility")
2344  (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2345{
2346  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2347  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2348  PyArrayObject* array = (PyArrayObject*) obj;
2349
2350  if (!array) SWIG_fail;
2351  $result = SWIG_Python_AppendOutput($result,obj);
2352}
2353
2354/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2355                      DATA_TYPE** ARGOUTVIEW_ARRAY4)
2356 */
2357%typemap(in,numinputs=0)
2358  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEW_ARRAY4)
2359  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL  )
2360{
2361  $1 = &dim1_temp;
2362  $2 = &dim2_temp;
2363  $3 = &dim3_temp;
2364  $4 = &dim4_temp;
2365  $5 = &data_temp;
2366}
2367%typemap(argout,
2368         fragment="NumPy_Backward_Compatibility")
2369  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
2370{
2371  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2372  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2373  PyArrayObject* array = (PyArrayObject*) obj;
2374
2375  if (!array) SWIG_fail;
2376  $result = SWIG_Python_AppendOutput($result,obj);
2377}
2378
2379/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2380                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2381 */
2382%typemap(in,numinputs=0)
2383  (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2384  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2385{
2386  $1 = &data_temp;
2387  $2 = &dim1_temp;
2388  $3 = &dim2_temp;
2389  $4 = &dim3_temp;
2390  $5 = &dim4_temp;
2391}
2392%typemap(argout,
2393         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2394  (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2395{
2396  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2397  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2398  PyArrayObject* array = (PyArrayObject*) obj;
2399
2400  if (!array || !require_fortran(array)) SWIG_fail;
2401  $result = SWIG_Python_AppendOutput($result,obj);
2402}
2403
2404/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2405                      DATA_TYPE** ARGOUTVIEW_FARRAY4)
2406 */
2407%typemap(in,numinputs=0)
2408  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEW_FARRAY4)
2409  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
2410{
2411  $1 = &dim1_temp;
2412  $2 = &dim2_temp;
2413  $3 = &dim3_temp;
2414  $4 = &dim4_temp;
2415  $5 = &data_temp;
2416}
2417%typemap(argout,
2418         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2419  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
2420{
2421  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2422  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2423  PyArrayObject* array = (PyArrayObject*) obj;
2424
2425  if (!array || !require_fortran(array)) SWIG_fail;
2426  $result = SWIG_Python_AppendOutput($result,obj);
2427}
2428
2429/*************************************/
2430/* Managed Argoutview Array Typemaps */
2431/*************************************/
2432
2433/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
2434 */
2435%typemap(in,numinputs=0)
2436  (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1    )
2437  (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim_temp)
2438{
2439  $1 = &data_temp;
2440  $2 = &dim_temp;
2441}
2442%typemap(argout,
2443         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2444  (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
2445{
2446  npy_intp dims[1] = { *$2 };
2447  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
2448  PyArrayObject* array = (PyArrayObject*) obj;
2449
2450  if (!array) SWIG_fail;
2451
2452%#ifdef SWIGPY_USE_CAPSULE
2453    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2454%#else
2455    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2456%#endif
2457
2458%#if NPY_API_VERSION < 0x00000007
2459  PyArray_BASE(array) = cap;
2460%#else
2461  PyArray_SetBaseObject(array,cap);
2462%#endif
2463
2464  $result = SWIG_Python_AppendOutput($result,obj);
2465}
2466
2467/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
2468 */
2469%typemap(in,numinputs=0)
2470  (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEWM_ARRAY1)
2471  (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp = NULL  )
2472{
2473  $1 = &dim_temp;
2474  $2 = &data_temp;
2475}
2476%typemap(argout,
2477         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2478  (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
2479{
2480  npy_intp dims[1] = { *$1 };
2481  PyObject* obj = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
2482  PyArrayObject* array = (PyArrayObject*) obj;
2483
2484  if (!array) SWIG_fail;
2485
2486%#ifdef SWIGPY_USE_CAPSULE
2487    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2488%#else
2489    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2490%#endif
2491
2492%#if NPY_API_VERSION < 0x00000007
2493  PyArray_BASE(array) = cap;
2494%#else
2495  PyArray_SetBaseObject(array,cap);
2496%#endif
2497
2498  $result = SWIG_Python_AppendOutput($result,obj);
2499}
2500
2501/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2502 */
2503%typemap(in,numinputs=0)
2504  (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
2505  (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
2506{
2507  $1 = &data_temp;
2508  $2 = &dim1_temp;
2509  $3 = &dim2_temp;
2510}
2511%typemap(argout,
2512         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2513  (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2514{
2515  npy_intp dims[2] = { *$2, *$3 };
2516  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
2517  PyArrayObject* array = (PyArrayObject*) obj;
2518
2519  if (!array) SWIG_fail;
2520
2521%#ifdef SWIGPY_USE_CAPSULE
2522    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2523%#else
2524    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2525%#endif
2526
2527%#if NPY_API_VERSION < 0x00000007
2528  PyArray_BASE(array) = cap;
2529%#else
2530  PyArray_SetBaseObject(array,cap);
2531%#endif
2532
2533  $result = SWIG_Python_AppendOutput($result,obj);
2534}
2535
2536/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
2537 */
2538%typemap(in,numinputs=0)
2539  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEWM_ARRAY2)
2540  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL  )
2541{
2542  $1 = &dim1_temp;
2543  $2 = &dim2_temp;
2544  $3 = &data_temp;
2545}
2546%typemap(argout,
2547         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2548  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
2549{
2550  npy_intp dims[2] = { *$1, *$2 };
2551  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
2552  PyArrayObject* array = (PyArrayObject*) obj;
2553
2554  if (!array) SWIG_fail;
2555
2556%#ifdef SWIGPY_USE_CAPSULE
2557    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2558%#else
2559    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2560%#endif
2561
2562%#if NPY_API_VERSION < 0x00000007
2563  PyArray_BASE(array) = cap;
2564%#else
2565  PyArray_SetBaseObject(array,cap);
2566%#endif
2567
2568  $result = SWIG_Python_AppendOutput($result,obj);
2569}
2570
2571/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2572 */
2573%typemap(in,numinputs=0)
2574  (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
2575  (DATA_TYPE*  data_temp = NULL   , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
2576{
2577  $1 = &data_temp;
2578  $2 = &dim1_temp;
2579  $3 = &dim2_temp;
2580}
2581%typemap(argout,
2582         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
2583  (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2584{
2585  npy_intp dims[2] = { *$2, *$3 };
2586  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
2587  PyArrayObject* array = (PyArrayObject*) obj;
2588
2589  if (!array || !require_fortran(array)) SWIG_fail;
2590
2591%#ifdef SWIGPY_USE_CAPSULE
2592    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2593%#else
2594    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2595%#endif
2596
2597%#if NPY_API_VERSION < 0x00000007
2598  PyArray_BASE(array) = cap;
2599%#else
2600  PyArray_SetBaseObject(array,cap);
2601%#endif
2602
2603  $result = SWIG_Python_AppendOutput($result,obj);
2604}
2605
2606/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
2607 */
2608%typemap(in,numinputs=0)
2609  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEWM_FARRAY2)
2610  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL   )
2611{
2612  $1 = &dim1_temp;
2613  $2 = &dim2_temp;
2614  $3 = &data_temp;
2615}
2616%typemap(argout,
2617         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
2618  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
2619{
2620  npy_intp dims[2] = { *$1, *$2 };
2621  PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
2622  PyArrayObject* array = (PyArrayObject*) obj;
2623
2624  if (!array || !require_fortran(array)) SWIG_fail;
2625
2626%#ifdef SWIGPY_USE_CAPSULE
2627    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2628%#else
2629    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2630%#endif
2631
2632%#if NPY_API_VERSION < 0x00000007
2633  PyArray_BASE(array) = cap;
2634%#else
2635  PyArray_SetBaseObject(array,cap);
2636%#endif
2637
2638  $result = SWIG_Python_AppendOutput($result,obj);
2639}
2640
2641/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2642                      DIM_TYPE* DIM3)
2643 */
2644%typemap(in,numinputs=0)
2645  (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
2646  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
2647{
2648  $1 = &data_temp;
2649  $2 = &dim1_temp;
2650  $3 = &dim2_temp;
2651  $4 = &dim3_temp;
2652}
2653%typemap(argout,
2654         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2655  (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2656{
2657  npy_intp dims[3] = { *$2, *$3, *$4 };
2658  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
2659  PyArrayObject* array = (PyArrayObject*) obj;
2660
2661  if (!array) SWIG_fail;
2662
2663%#ifdef SWIGPY_USE_CAPSULE
2664    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2665%#else
2666    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2667%#endif
2668
2669%#if NPY_API_VERSION < 0x00000007
2670  PyArray_BASE(array) = cap;
2671%#else
2672  PyArray_SetBaseObject(array,cap);
2673%#endif
2674
2675  $result = SWIG_Python_AppendOutput($result,obj);
2676}
2677
2678/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
2679                      DATA_TYPE** ARGOUTVIEWM_ARRAY3)
2680 */
2681%typemap(in,numinputs=0)
2682  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEWM_ARRAY3)
2683  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL   )
2684{
2685  $1 = &dim1_temp;
2686  $2 = &dim2_temp;
2687  $3 = &dim3_temp;
2688  $4 = &data_temp;
2689}
2690%typemap(argout,
2691         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2692  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
2693{
2694  npy_intp dims[3] = { *$1, *$2, *$3 };
2695  PyObject* obj= PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
2696  PyArrayObject* array = (PyArrayObject*) obj;
2697
2698  if (!array) SWIG_fail;
2699
2700%#ifdef SWIGPY_USE_CAPSULE
2701    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2702%#else
2703    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2704%#endif
2705
2706%#if NPY_API_VERSION < 0x00000007
2707  PyArray_BASE(array) = cap;
2708%#else
2709  PyArray_SetBaseObject(array,cap);
2710%#endif
2711
2712  $result = SWIG_Python_AppendOutput($result,obj);
2713}
2714
2715/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2716                      DIM_TYPE* DIM3)
2717 */
2718%typemap(in,numinputs=0)
2719  (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
2720  (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
2721{
2722  $1 = &data_temp;
2723  $2 = &dim1_temp;
2724  $3 = &dim2_temp;
2725  $4 = &dim3_temp;
2726}
2727%typemap(argout,
2728         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
2729  (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2730{
2731  npy_intp dims[3] = { *$2, *$3, *$4 };
2732  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
2733  PyArrayObject* array = (PyArrayObject*) obj;
2734
2735  if (!array || !require_fortran(array)) SWIG_fail;
2736
2737%#ifdef SWIGPY_USE_CAPSULE
2738    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2739%#else
2740    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2741%#endif
2742
2743%#if NPY_API_VERSION < 0x00000007
2744  PyArray_BASE(array) = cap;
2745%#else
2746  PyArray_SetBaseObject(array,cap);
2747%#endif
2748
2749  $result = SWIG_Python_AppendOutput($result,obj);
2750}
2751
2752/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
2753                      DATA_TYPE** ARGOUTVIEWM_FARRAY3)
2754 */
2755%typemap(in,numinputs=0)
2756  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEWM_FARRAY3)
2757  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL    )
2758{
2759  $1 = &dim1_temp;
2760  $2 = &dim2_temp;
2761  $3 = &dim3_temp;
2762  $4 = &data_temp;
2763}
2764%typemap(argout,
2765         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
2766  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
2767{
2768  npy_intp dims[3] = { *$1, *$2, *$3 };
2769  PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
2770  PyArrayObject* array = (PyArrayObject*) obj;
2771
2772  if (!array || !require_fortran(array)) SWIG_fail;
2773
2774%#ifdef SWIGPY_USE_CAPSULE
2775    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2776%#else
2777    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2778%#endif
2779
2780%#if NPY_API_VERSION < 0x00000007
2781  PyArray_BASE(array) = cap;
2782%#else
2783  PyArray_SetBaseObject(array,cap);
2784%#endif
2785
2786  $result = SWIG_Python_AppendOutput($result,obj);
2787}
2788
2789/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2790                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2791 */
2792%typemap(in,numinputs=0)
2793  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2794  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2795{
2796  $1 = &data_temp;
2797  $2 = &dim1_temp;
2798  $3 = &dim2_temp;
2799  $4 = &dim3_temp;
2800  $5 = &dim4_temp;
2801}
2802%typemap(argout,
2803         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2804  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2805{
2806  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2807  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2808  PyArrayObject* array = (PyArrayObject*) obj;
2809
2810  if (!array) SWIG_fail;
2811
2812%#ifdef SWIGPY_USE_CAPSULE
2813    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2814%#else
2815    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2816%#endif
2817
2818%#if NPY_API_VERSION < 0x00000007
2819  PyArray_BASE(array) = cap;
2820%#else
2821  PyArray_SetBaseObject(array,cap);
2822%#endif
2823
2824  $result = SWIG_Python_AppendOutput($result,obj);
2825}
2826
2827/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2828                      DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2829 */
2830%typemap(in,numinputs=0)
2831  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2832  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
2833{
2834  $1 = &dim1_temp;
2835  $2 = &dim2_temp;
2836  $3 = &dim3_temp;
2837  $4 = &dim4_temp;
2838  $5 = &data_temp;
2839}
2840%typemap(argout,
2841         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2842  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2843{
2844  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2845  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2846  PyArrayObject* array = (PyArrayObject*) obj;
2847
2848  if (!array) SWIG_fail;
2849
2850%#ifdef SWIGPY_USE_CAPSULE
2851    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2852%#else
2853    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2854%#endif
2855
2856%#if NPY_API_VERSION < 0x00000007
2857  PyArray_BASE(array) = cap;
2858%#else
2859  PyArray_SetBaseObject(array,cap);
2860%#endif
2861
2862  $result = SWIG_Python_AppendOutput($result,obj);
2863}
2864
2865/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2866                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2867 */
2868%typemap(in,numinputs=0)
2869  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2870  (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2871{
2872  $1 = &data_temp;
2873  $2 = &dim1_temp;
2874  $3 = &dim2_temp;
2875  $4 = &dim3_temp;
2876  $5 = &dim4_temp;
2877}
2878%typemap(argout,
2879         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
2880  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2881{
2882  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2883  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2884  PyArrayObject* array = (PyArrayObject*) obj;
2885
2886  if (!array || !require_fortran(array)) SWIG_fail;
2887
2888%#ifdef SWIGPY_USE_CAPSULE
2889    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2890%#else
2891    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2892%#endif
2893
2894%#if NPY_API_VERSION < 0x00000007
2895  PyArray_BASE(array) = cap;
2896%#else
2897  PyArray_SetBaseObject(array,cap);
2898%#endif
2899
2900  $result = SWIG_Python_AppendOutput($result,obj);
2901}
2902
2903/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2904                      DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2905 */
2906%typemap(in,numinputs=0)
2907  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2908  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL    )
2909{
2910  $1 = &dim1_temp;
2911  $2 = &dim2_temp;
2912  $3 = &dim3_temp;
2913  $4 = &dim4_temp;
2914  $5 = &data_temp;
2915}
2916%typemap(argout,
2917         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
2918  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2919{
2920  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2921  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2922  PyArrayObject* array = (PyArrayObject*) obj;
2923
2924  if (!array || !require_fortran(array)) SWIG_fail;
2925
2926%#ifdef SWIGPY_USE_CAPSULE
2927    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2928%#else
2929    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2930%#endif
2931
2932%#if NPY_API_VERSION < 0x00000007
2933  PyArray_BASE(array) = cap;
2934%#else
2935  PyArray_SetBaseObject(array,cap);
2936%#endif
2937
2938  $result = SWIG_Python_AppendOutput($result,obj);
2939}
2940
2941/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2942                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2943 */
2944%typemap(in,numinputs=0)
2945  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2946  (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2947{
2948  $1 = &data_temp;
2949  $2 = &dim1_temp;
2950  $3 = &dim2_temp;
2951  $4 = &dim3_temp;
2952  $5 = &dim4_temp;
2953}
2954%typemap(argout,
2955         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2956  (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2957{
2958  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2959  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2960  PyArrayObject* array = (PyArrayObject*) obj;
2961
2962  if (!array) SWIG_fail;
2963
2964%#ifdef SWIGPY_USE_CAPSULE
2965    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
2966%#else
2967    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
2968%#endif
2969
2970%#if NPY_API_VERSION < 0x00000007
2971  PyArray_BASE(array) = cap;
2972%#else
2973  PyArray_SetBaseObject(array,cap);
2974%#endif
2975
2976  $result = SWIG_Python_AppendOutput($result,obj);
2977}
2978
2979/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2980                      DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2981 */
2982%typemap(in,numinputs=0)
2983  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2984  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
2985{
2986  $1 = &dim1_temp;
2987  $2 = &dim2_temp;
2988  $3 = &dim3_temp;
2989  $4 = &dim4_temp;
2990  $5 = &data_temp;
2991}
2992%typemap(argout,
2993         fragment="NumPy_Backward_Compatibility,NumPy_Utilities")
2994  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2995{
2996  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2997  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2998  PyArrayObject* array = (PyArrayObject*) obj;
2999
3000  if (!array) SWIG_fail;
3001
3002%#ifdef SWIGPY_USE_CAPSULE
3003    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
3004%#else
3005    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
3006%#endif
3007
3008%#if NPY_API_VERSION < 0x00000007
3009  PyArray_BASE(array) = cap;
3010%#else
3011  PyArray_SetBaseObject(array,cap);
3012%#endif
3013
3014  $result = SWIG_Python_AppendOutput($result,obj);
3015}
3016
3017/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
3018                      DIM_TYPE* DIM3, DIM_TYPE* DIM4)
3019 */
3020%typemap(in,numinputs=0)
3021  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
3022  (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
3023{
3024  $1 = &data_temp;
3025  $2 = &dim1_temp;
3026  $3 = &dim2_temp;
3027  $4 = &dim3_temp;
3028  $5 = &dim4_temp;
3029}
3030%typemap(argout,
3031         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
3032  (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
3033{
3034  npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
3035  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
3036  PyArrayObject* array = (PyArrayObject*) obj;
3037
3038  if (!array || !require_fortran(array)) SWIG_fail;
3039
3040%#ifdef SWIGPY_USE_CAPSULE
3041    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
3042%#else
3043    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
3044%#endif
3045
3046%#if NPY_API_VERSION < 0x00000007
3047  PyArray_BASE(array) = cap;
3048%#else
3049  PyArray_SetBaseObject(array,cap);
3050%#endif
3051
3052  $result = SWIG_Python_AppendOutput($result,obj);
3053}
3054
3055/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
3056                      DATA_TYPE** ARGOUTVIEWM_FARRAY4)
3057 */
3058%typemap(in,numinputs=0)
3059  (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_FARRAY4)
3060  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL    )
3061{
3062  $1 = &dim1_temp;
3063  $2 = &dim2_temp;
3064  $3 = &dim3_temp;
3065  $4 = &dim4_temp;
3066  $5 = &data_temp;
3067}
3068%typemap(argout,
3069         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities")
3070  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
3071{
3072  npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
3073  PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
3074  PyArrayObject* array = (PyArrayObject*) obj;
3075
3076  if (!array || !require_fortran(array)) SWIG_fail;
3077
3078%#ifdef SWIGPY_USE_CAPSULE
3079    PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap);
3080%#else
3081    PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free);
3082%#endif
3083
3084%#if NPY_API_VERSION < 0x00000007
3085  PyArray_BASE(array) = cap;
3086%#else
3087  PyArray_SetBaseObject(array,cap);
3088%#endif
3089
3090  $result = SWIG_Python_AppendOutput($result,obj);
3091}
3092
3093/**************************************/
3094/* In-Place Array Typemap - flattened */
3095/**************************************/
3096
3097/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT)
3098 */
3099%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
3100           fragment="NumPy_Macros")
3101  (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT)
3102{
3103  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
3104                                                 DATA_TYPECODE);
3105}
3106%typemap(in,
3107         fragment="NumPy_Fragments")
3108  (DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT)
3109  (PyArrayObject* array=NULL, int i=1)
3110{
3111  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
3112  if (!array || !require_c_or_f_contiguous(array)
3113      || !require_native(array)) SWIG_fail;
3114  $1 = (DATA_TYPE*) array_data(array);
3115  $2 = 1;
3116  for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
3117}
3118
3119%enddef    /* %numpy_typemaps() macro */
3120/* *************************************************************** */
3121
3122/* Concrete instances of the %numpy_typemaps() macro: Each invocation
3123 * below applies all of the typemaps above to the specified data type.
3124 */
3125%numpy_typemaps(signed char       , NPY_BYTE     , int)
3126%numpy_typemaps(unsigned char     , NPY_UBYTE    , int)
3127%numpy_typemaps(short             , NPY_SHORT    , int)
3128%numpy_typemaps(unsigned short    , NPY_USHORT   , int)
3129%numpy_typemaps(int               , NPY_INT      , int)
3130%numpy_typemaps(unsigned int      , NPY_UINT     , int)
3131%numpy_typemaps(long              , NPY_LONG     , int)
3132%numpy_typemaps(unsigned long     , NPY_ULONG    , int)
3133%numpy_typemaps(long long         , NPY_LONGLONG , int)
3134%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
3135%numpy_typemaps(float             , NPY_FLOAT    , int)
3136%numpy_typemaps(double            , NPY_DOUBLE   , int)
3137
3138/* ***************************************************************
3139 * The follow macro expansion does not work, because C++ bool is 4
3140 * bytes and NPY_BOOL is 1 byte
3141 *
3142 *    %numpy_typemaps(bool, NPY_BOOL, int)
3143 */
3144
3145/* ***************************************************************
3146 * On my Mac, I get the following warning for this macro expansion:
3147 * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
3148 *
3149 *    %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
3150 */
3151
3152#ifdef __cplusplus
3153
3154%include <std_complex.i>
3155
3156%numpy_typemaps(std::complex<float>,  NPY_CFLOAT , int)
3157%numpy_typemaps(std::complex<double>, NPY_CDOUBLE, int)
3158
3159#endif
3160
3161#endif /* SWIGPYTHON */
Note: See TracBrowser for help on using the repository browser.