1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 //          PyTrilinos: Python Interfaces to Trilinos Packages
6 //                 Copyright (2014) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia
9 // Corporation, the U.S. Government retains certain rights in this
10 // software.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact William F. Spotz (wfspotz@sandia.gov)
40 //
41 // ***********************************************************************
42 // @HEADER
43 */
44 
45 /* -*- C -*-  (not really, but good for syntax highlighting) */
46 #ifdef SWIGPYTHON
47 
48 %{
49 #ifndef SWIG_FILE_WITH_INIT
50 #  define NO_IMPORT_ARRAY
51 #endif
52 #include "stdio.h"
53 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
54 #include <numpy/arrayobject.h>
55 %}
56 
57 /**********************************************************************/
58 
59 %fragment("NumPy_Backward_Compatibility", "header")
60 {
61 %#if NPY_API_VERSION < 0x00000007
62 %#define NPY_ARRAY_DEFAULT NPY_DEFAULT
63 %#define NPY_ARRAY_FARRAY  NPY_FARRAY
64 %#define NPY_FORTRANORDER  NPY_FORTRAN
65 %#endif
66 }
67 
68 /**********************************************************************/
69 
70 /* The following code originally appeared in
71  * enthought/kiva/agg/src/numeric.i written by Eric Jones.  It was
72  * translated from C++ to C by John Hunter.  Bill Spotz has modified
73  * it to fix some minor bugs, upgrade from Numeric to numpy (all
74  * versions), add some comments and functionality, and convert from
75  * direct code insertion to SWIG fragments.
76  */
77 
78 %fragment("NumPy_Macros", "header")
79 {
80 /* Macros to extract array attributes.
81  */
82 %#if NPY_API_VERSION < 0x00000007
83 %#define is_array(a)            ((a) && PyArray_Check((PyArrayObject*)a))
84 %#define array_type(a)          (int)(PyArray_TYPE((PyArrayObject*)a))
85 %#define array_numdims(a)       (((PyArrayObject*)a)->nd)
86 %#define array_dimensions(a)    (((PyArrayObject*)a)->dimensions)
87 %#define array_size(a,i)        (((PyArrayObject*)a)->dimensions[i])
88 %#define array_strides(a)       (((PyArrayObject*)a)->strides)
89 %#define array_stride(a,i)      (((PyArrayObject*)a)->strides[i])
90 %#define array_data(a)          (((PyArrayObject*)a)->data)
91 %#define array_descr(a)         (((PyArrayObject*)a)->descr)
92 %#define array_flags(a)         (((PyArrayObject*)a)->flags)
93 %#define array_enableflags(a,f) (((PyArrayObject*)a)->flags) = f
94 %#else
95 %#define is_array(a)            ((a) && PyArray_Check(a))
96 %#define array_type(a)          PyArray_TYPE((PyArrayObject*)a)
97 %#define array_numdims(a)       PyArray_NDIM((PyArrayObject*)a)
98 %#define array_dimensions(a)    PyArray_DIMS((PyArrayObject*)a)
99 %#define array_strides(a)       PyArray_STRIDES((PyArrayObject*)a)
100 %#define array_stride(a,i)      PyArray_STRIDE((PyArrayObject*)a,i)
101 %#define array_size(a,i)        PyArray_DIM((PyArrayObject*)a,i)
102 %#define array_data(a)          PyArray_DATA((PyArrayObject*)a)
103 %#define array_descr(a)         PyArray_DESCR((PyArrayObject*)a)
104 %#define array_flags(a)         PyArray_FLAGS((PyArrayObject*)a)
105 %#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f)
106 %#endif
107 %#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a))
108 %#define array_is_native(a)     (PyArray_ISNOTSWAPPED((PyArrayObject*)a))
109 %#define array_is_fortran(a)    (PyArray_ISFORTRAN((PyArrayObject*)a))
110 }
111 
112 /**********************************************************************/
113 
114 %fragment("NumPy_Utilities",
115           "header")
116 {
117   /* Given a PyObject, return a string describing its type.
118    */
119   const char* pytype_string(PyObject* py_obj)
120   {
121     if (py_obj == NULL          ) return "C NULL value";
122     if (py_obj == Py_None       ) return "Python None" ;
123     if (PyCallable_Check(py_obj)) return "callable"    ;
124     if (PyString_Check(  py_obj)) return "string"      ;
125     if (PyInt_Check(     py_obj)) return "int"         ;
126     if (PyFloat_Check(   py_obj)) return "float"       ;
127     if (PyDict_Check(    py_obj)) return "dict"        ;
128     if (PyList_Check(    py_obj)) return "list"        ;
129     if (PyTuple_Check(   py_obj)) return "tuple"       ;
130 %#if PY_MAJOR_VERSION < 3
131     if (PyFile_Check(    py_obj)) return "file"        ;
132     if (PyModule_Check(  py_obj)) return "module"      ;
133     if (PyInstance_Check(py_obj)) return "instance"    ;
134 %#endif
135 
136     return "unkown type";
137   }
138 
139   /* Given a NumPy typecode, return a string describing the type.
140    */
141   const char* typecode_string(int typecode)
142   {
143     static const char* type_names[25] = {"bool",
144                                          "byte",
145                                          "unsigned byte",
146                                          "short",
147                                          "unsigned short",
148                                          "int",
149                                          "unsigned int",
150                                          "long",
151                                          "unsigned long",
152                                          "long long",
153                                          "unsigned long long",
154                                          "float",
155                                          "double",
156                                          "long double",
157                                          "complex float",
158                                          "complex double",
159                                          "complex long double",
160                                          "object",
161                                          "string",
162                                          "unicode",
163                                          "void",
164                                          "ntypes",
165                                          "notype",
166                                          "char",
167                                          "unknown"};
168     return typecode < 24 ? type_names[typecode] : type_names[24];
169   }
170 
171   /* Make sure input has correct numpy type.  This now just calls
172      PyArray_EquivTypenums().
173    */
174   int type_match(int actual_type,
175                  int desired_type)
176   {
177     return PyArray_EquivTypenums(actual_type, desired_type);
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_FORTRANORDER);
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   /* Require that a numpy array is not byte-swapped.  If the array is
385    * not byte-swapped, return 1.  Otherwise, set the python error string
386    * and return 0.
387    */
388   int require_native(PyArrayObject* ary)
389   {
390     int native = 1;
391     if (!array_is_native(ary))
392     {
393       PyErr_SetString(PyExc_TypeError,
394                       "Array must have native byteorder.  "
395                       "A byte-swapped array was given");
396       native = 0;
397     }
398     return native;
399   }
400 
401   /* Require the given PyArrayObject to have a specified number of
402    * dimensions.  If the array has the specified number of dimensions,
403    * return 1.  Otherwise, set the python error string and return 0.
404    */
405   int require_dimensions(PyArrayObject* ary,
406                          int            exact_dimensions)
407   {
408     int success = 1;
409     if (array_numdims(ary) != exact_dimensions)
410     {
411       PyErr_Format(PyExc_TypeError,
412                    "Array must have %d dimensions.  Given array has %d dimensions",
413                    exact_dimensions,
414                    array_numdims(ary));
415       success = 0;
416     }
417     return success;
418   }
419 
420   /* Require the given PyArrayObject to have one of a list of specified
421    * number of dimensions.  If the array has one of the specified number
422    * of dimensions, return 1.  Otherwise, set the python error string
423    * and return 0.
424    */
425   int require_dimensions_n(PyArrayObject* ary,
426                            int*           exact_dimensions,
427                            int            n)
428   {
429     int success = 0;
430     int i;
431     char dims_str[255] = "";
432     char s[255];
433     for (i = 0; i < n && !success; i++)
434     {
435       if (array_numdims(ary) == exact_dimensions[i])
436       {
437         success = 1;
438       }
439     }
440     if (!success)
441     {
442       for (i = 0; i < n-1; i++)
443       {
444         sprintf(s, "%d, ", exact_dimensions[i]);
445         strcat(dims_str,s);
446       }
447       sprintf(s, " or %d", exact_dimensions[n-1]);
448       strcat(dims_str,s);
449       PyErr_Format(PyExc_TypeError,
450                    "Array must have %s dimensions.  Given array has %d dimensions",
451                    dims_str,
452                    array_numdims(ary));
453     }
454     return success;
455   }
456 
457   /* Require the given PyArrayObject to have a specified shape.  If the
458    * array has the specified shape, return 1.  Otherwise, set the python
459    * error string and return 0.
460    */
461   int require_size(PyArrayObject* ary,
462                    npy_intp*      size,
463                    int            n)
464   {
465     int i;
466     int success = 1;
467     int len;
468     char desired_dims[255] = "[";
469     char s[255];
470     char actual_dims[255] = "[";
471     for(i=0; i < n;i++)
472     {
473       if (size[i] != -1 &&  size[i] != array_size(ary,i))
474       {
475         success = 0;
476       }
477     }
478     if (!success)
479     {
480       for (i = 0; i < n; i++)
481       {
482         if (size[i] == -1)
483         {
484           sprintf(s, "*,");
485         }
486         else
487         {
488           sprintf(s, "%ld,", (long int)size[i]);
489         }
490         strcat(desired_dims,s);
491       }
492       len = strlen(desired_dims);
493       desired_dims[len-1] = ']';
494       for (i = 0; i < n; i++)
495       {
496         sprintf(s, "%ld,", (long int)array_size(ary,i));
497         strcat(actual_dims,s);
498       }
499       len = strlen(actual_dims);
500       actual_dims[len-1] = ']';
501       PyErr_Format(PyExc_TypeError,
502                    "Array must have shape of %s.  Given array has shape of %s",
503                    desired_dims,
504                    actual_dims);
505     }
506     return success;
507   }
508 
509   /* Require the given PyArrayObject to to be Fortran ordered.  If the
510    * the PyArrayObject is already Fortran ordered, do nothing.  Else,
511    * set the Fortran ordering flag and recompute the strides.
512    */
513   int require_fortran(PyArrayObject* ary)
514   {
515     int success = 1;
516     int nd = array_numdims(ary);
517     int i;
518     npy_intp * strides = array_strides(ary);
519     if (array_is_fortran(ary)) return success;
520     /* Set the Fortran ordered flag */
521     array_enableflags(ary,NPY_ARRAY_FARRAY);
522     /* Recompute the strides */
523     strides[0] = strides[nd-1];
524     for (i=1; i < nd; ++i)
525       strides[i] = strides[i-1] * array_size(ary,i-1);
526     return success;
527   }
528 }
529 
530 /* Combine all NumPy fragments into one for convenience */
531 %fragment("NumPy_Fragments",
532           "header",
533           fragment="NumPy_Backward_Compatibility",
534           fragment="NumPy_Macros",
535           fragment="NumPy_Utilities",
536           fragment="NumPy_Object_to_Array",
537           fragment="NumPy_Array_Requirements")
538 {
539 }
540 
541 /* End John Hunter translation (with modifications by Bill Spotz)
542  */
543 
544 /* %numpy_typemaps() macro
545  *
546  * This macro defines a family of 70 typemaps that allow C arguments
547  * of the form
548  *
549  *    1. (DATA_TYPE IN_ARRAY1[ANY])
550  *    2. (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
551  *    3. (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
552  *
553  *    4. (DATA_TYPE IN_ARRAY2[ANY][ANY])
554  *    5. (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
555  *    6. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
556  *    7. (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
557  *    8. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
558  *
559  *    9. (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
560  *   10. (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
561  *   11. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
562  *   12. (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
563  *   13. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
564  *
565  *   14. (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
566  *   15. (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
567  *   16. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, , DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
568  *   17. (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
569  *   18. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
570  *
571  *   19. (DATA_TYPE INPLACE_ARRAY1[ANY])
572  *   20. (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
573  *   21. (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
574  *
575  *   22. (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
576  *   23. (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
577  *   24. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
578  *   25. (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
579  *   26. (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
580  *
581  *   27. (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
582  *   28. (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
583  *   29. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
584  *   30. (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
585  *   31. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
586  *
587  *   32. (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
588  *   33. (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
589  *   34. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
590  *   35. (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
591  *   36. (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
592  *
593  *   37. (DATA_TYPE ARGOUT_ARRAY1[ANY])
594  *   38. (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
595  *   39. (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
596  *
597  *   40. (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
598  *
599  *   41. (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
600  *
601  *   42. (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
602  *
603  *   43. (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
604  *   44. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
605  *
606  *   45. (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
607  *   46. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
608  *   47. (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
609  *   48. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
610  *
611  *   49. (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
612  *   50. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
613  *   51. (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
614  *   52. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
615  *
616  *   53. (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
617  *   54. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
618  *   55. (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
619  *   56. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
620  *
621  *   57. (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
622  *   58. (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
623  *
624  *   59. (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
625  *   60. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
626  *   61. (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
627  *   62. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
628  *
629  *   63. (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
630  *   64. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
631  *   65. (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
632  *   66. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
633  *
634  *   67. (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
635  *   68. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
636  *   69. (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
637  *   70. (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
638  *
639  * where "DATA_TYPE" is any type supported by the NumPy module, and
640  * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
641  * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
642  * that the "FARRAY" typemaps expect Fortran ordering of
643  * multidimensional arrays.  In python, the dimensions will not need
644  * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
645  * typemaps).  The IN_ARRAYs can be a numpy array or any sequence that
646  * can be converted to a numpy array of the specified type.  The
647  * INPLACE_ARRAYs must be numpy arrays of the appropriate type.  The
648  * ARGOUT_ARRAYs will be returned as new numpy arrays of the
649  * appropriate type.
650  *
651  * These typemaps can be applied to existing functions using the
652  * %apply directive.  For example:
653  *
654  *     %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
655  *     double prod(double* series, int length);
656  *
657  *     %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
658  *           {(int rows, int cols, double* matrix        )};
659  *     void floor(int rows, int cols, double* matrix, double f);
660  *
661  *     %apply (double IN_ARRAY3[ANY][ANY][ANY])
662  *           {(double tensor[2][2][2]         )};
663  *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
664  *           {(double low[2][2][2]                )};
665  *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
666  *           {(double upp[2][2][2]                )};
667  *     void luSplit(double tensor[2][2][2],
668  *                  double low[2][2][2],
669  *                  double upp[2][2][2]    );
670  *
671  * or directly with
672  *
673  *     double prod(double* IN_ARRAY1, int DIM1);
674  *
675  *     void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
676  *
677  *     void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
678  *                  double ARGOUT_ARRAY3[ANY][ANY][ANY],
679  *                  double ARGOUT_ARRAY3[ANY][ANY][ANY]);
680  */
681 
682 %define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
683 
684 /************************/
685 /* Input Array Typemaps */
686 /************************/
687 
688 /* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
689  */
690 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
691            fragment="NumPy_Macros")
692   (DATA_TYPE IN_ARRAY1[ANY])
693 {
694   $1 = is_array($input) || PySequence_Check($input);
695 }
696 %typemap(in,
697          fragment="NumPy_Fragments")
698   (DATA_TYPE IN_ARRAY1[ANY])
699   (PyArrayObject* array=NULL, int is_new_object=0)
700 {
701   npy_intp size[1] = { $1_dim0 };
702   array = obj_to_array_contiguous_allow_conversion($input,
703                                                    DATA_TYPECODE,
704                                                    &is_new_object);
705   if (!array || !require_dimensions(array, 1) ||
706       !require_size(array, size, 1)) SWIG_fail;
707   $1 = ($1_ltype) array_data(array);
708 }
709 %typemap(freearg)
710   (DATA_TYPE IN_ARRAY1[ANY])
711 {
712   if (is_new_object$argnum && array$argnum)
713     { Py_DECREF(array$argnum); }
714 }
715 
716 /* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
717  */
718 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
719            fragment="NumPy_Macros")
720   (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
721 {
722   $1 = is_array($input) || PySequence_Check($input);
723 }
724 %typemap(in,
725          fragment="NumPy_Fragments")
726   (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
727   (PyArrayObject* array=NULL, int is_new_object=0)
728 {
729   npy_intp size[1] = { -1 };
730   array = obj_to_array_contiguous_allow_conversion($input,
731                                                    DATA_TYPECODE,
732                                                    &is_new_object);
733   if (!array || !require_dimensions(array, 1) ||
734       !require_size(array, size, 1)) SWIG_fail;
735   $1 = (DATA_TYPE*) array_data(array);
736   $2 = (DIM_TYPE) array_size(array,0);
737 }
738 %typemap(freearg)
739   (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
740 {
741   if (is_new_object$argnum && array$argnum)
742     { Py_DECREF(array$argnum); }
743 }
744 
745 /* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
746  */
747 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
748            fragment="NumPy_Macros")
749   (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
750 {
751   $1 = is_array($input) || PySequence_Check($input);
752 }
753 %typemap(in,
754          fragment="NumPy_Fragments")
755   (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
756   (PyArrayObject* array=NULL, int is_new_object=0)
757 {
758   npy_intp size[1] = {-1};
759   array = obj_to_array_contiguous_allow_conversion($input,
760                                                    DATA_TYPECODE,
761                                                    &is_new_object);
762   if (!array || !require_dimensions(array, 1) ||
763       !require_size(array, size, 1)) SWIG_fail;
764   $1 = (DIM_TYPE) array_size(array,0);
765   $2 = (DATA_TYPE*) array_data(array);
766 }
767 %typemap(freearg)
768   (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
769 {
770   if (is_new_object$argnum && array$argnum)
771     { Py_DECREF(array$argnum); }
772 }
773 
774 /* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
775  */
776 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
777            fragment="NumPy_Macros")
778   (DATA_TYPE IN_ARRAY2[ANY][ANY])
779 {
780   $1 = is_array($input) || PySequence_Check($input);
781 }
782 %typemap(in,
783          fragment="NumPy_Fragments")
784   (DATA_TYPE IN_ARRAY2[ANY][ANY])
785   (PyArrayObject* array=NULL, int is_new_object=0)
786 {
787   npy_intp size[2] = { $1_dim0, $1_dim1 };
788   array = obj_to_array_contiguous_allow_conversion($input,
789                                                    DATA_TYPECODE,
790                                                    &is_new_object);
791   if (!array || !require_dimensions(array, 2) ||
792       !require_size(array, size, 2)) SWIG_fail;
793   $1 = ($1_ltype) array_data(array);
794 }
795 %typemap(freearg)
796   (DATA_TYPE IN_ARRAY2[ANY][ANY])
797 {
798   if (is_new_object$argnum && array$argnum)
799     { Py_DECREF(array$argnum); }
800 }
801 
802 /* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
803  */
804 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
805            fragment="NumPy_Macros")
806   (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
807 {
808   $1 = is_array($input) || PySequence_Check($input);
809 }
810 %typemap(in,
811          fragment="NumPy_Fragments")
812   (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
813   (PyArrayObject* array=NULL, int is_new_object=0)
814 {
815   npy_intp size[2] = { -1, -1 };
816   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
817                                                    &is_new_object);
818   if (!array || !require_dimensions(array, 2) ||
819       !require_size(array, size, 2)) SWIG_fail;
820   $1 = (DATA_TYPE*) array_data(array);
821   $2 = (DIM_TYPE) array_size(array,0);
822   $3 = (DIM_TYPE) array_size(array,1);
823 }
824 %typemap(freearg)
825   (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
826 {
827   if (is_new_object$argnum && array$argnum)
828     { Py_DECREF(array$argnum); }
829 }
830 
831 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
832  */
833 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
834            fragment="NumPy_Macros")
835   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
836 {
837   $1 = is_array($input) || PySequence_Check($input);
838 }
839 %typemap(in,
840          fragment="NumPy_Fragments")
841   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
842   (PyArrayObject* array=NULL, int is_new_object=0)
843 {
844   npy_intp size[2] = { -1, -1 };
845   array = obj_to_array_contiguous_allow_conversion($input,
846                                                    DATA_TYPECODE,
847                                                    &is_new_object);
848   if (!array || !require_dimensions(array, 2) ||
849       !require_size(array, size, 2)) SWIG_fail;
850   $1 = (DIM_TYPE) array_size(array,0);
851   $2 = (DIM_TYPE) array_size(array,1);
852   $3 = (DATA_TYPE*) array_data(array);
853 }
854 %typemap(freearg)
855   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
856 {
857   if (is_new_object$argnum && array$argnum)
858     { Py_DECREF(array$argnum); }
859 }
860 
861 /* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
862  */
863 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
864            fragment="NumPy_Macros")
865   (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
866 {
867   $1 = is_array($input) || PySequence_Check($input);
868 }
869 %typemap(in,
870          fragment="NumPy_Fragments")
871   (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
872   (PyArrayObject* array=NULL, int is_new_object=0)
873 {
874   npy_intp size[2] = { -1, -1 };
875   array = obj_to_array_fortran_allow_conversion($input,
876                                                 DATA_TYPECODE,
877                                                 &is_new_object);
878   if (!array || !require_dimensions(array, 2) ||
879       !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
880   $1 = (DATA_TYPE*) array_data(array);
881   $2 = (DIM_TYPE) array_size(array,0);
882   $3 = (DIM_TYPE) array_size(array,1);
883 }
884 %typemap(freearg)
885   (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
886 {
887   if (is_new_object$argnum && array$argnum)
888     { Py_DECREF(array$argnum); }
889 }
890 
891 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
892  */
893 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
894            fragment="NumPy_Macros")
895   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
896 {
897   $1 = is_array($input) || PySequence_Check($input);
898 }
899 %typemap(in,
900          fragment="NumPy_Fragments")
901   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
902   (PyArrayObject* array=NULL, int is_new_object=0)
903 {
904   npy_intp size[2] = { -1, -1 };
905   array = obj_to_array_contiguous_allow_conversion($input,
906                                                    DATA_TYPECODE,
907                                                    &is_new_object);
908   if (!array || !require_dimensions(array, 2) ||
909       !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
910   $1 = (DIM_TYPE) array_size(array,0);
911   $2 = (DIM_TYPE) array_size(array,1);
912   $3 = (DATA_TYPE*) array_data(array);
913 }
914 %typemap(freearg)
915   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
916 {
917   if (is_new_object$argnum && array$argnum)
918     { Py_DECREF(array$argnum); }
919 }
920 
921 /* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
922  */
923 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
924            fragment="NumPy_Macros")
925   (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
926 {
927   $1 = is_array($input) || PySequence_Check($input);
928 }
929 %typemap(in,
930          fragment="NumPy_Fragments")
931   (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
932   (PyArrayObject* array=NULL, int is_new_object=0)
933 {
934   npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
935   array = obj_to_array_contiguous_allow_conversion($input,
936                                                    DATA_TYPECODE,
937                                                    &is_new_object);
938   if (!array || !require_dimensions(array, 3) ||
939       !require_size(array, size, 3)) SWIG_fail;
940   $1 = ($1_ltype) array_data(array);
941 }
942 %typemap(freearg)
943   (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
944 {
945   if (is_new_object$argnum && array$argnum)
946     { Py_DECREF(array$argnum); }
947 }
948 
949 /* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
950  *                    DIM_TYPE DIM3)
951  */
952 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
953            fragment="NumPy_Macros")
954   (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
955 {
956   $1 = is_array($input) || PySequence_Check($input);
957 }
958 %typemap(in,
959          fragment="NumPy_Fragments")
960   (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
961   (PyArrayObject* array=NULL, int is_new_object=0)
962 {
963   npy_intp size[3] = { -1, -1, -1 };
964   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
965                                                    &is_new_object);
966   if (!array || !require_dimensions(array, 3) ||
967       !require_size(array, size, 3)) SWIG_fail;
968   $1 = (DATA_TYPE*) array_data(array);
969   $2 = (DIM_TYPE) array_size(array,0);
970   $3 = (DIM_TYPE) array_size(array,1);
971   $4 = (DIM_TYPE) array_size(array,2);
972 }
973 %typemap(freearg)
974   (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
975 {
976   if (is_new_object$argnum && array$argnum)
977     { Py_DECREF(array$argnum); }
978 }
979 
980 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
981  *                    DATA_TYPE* IN_ARRAY3)
982  */
983 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
984            fragment="NumPy_Macros")
985   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
986 {
987   $1 = is_array($input) || PySequence_Check($input);
988 }
989 %typemap(in,
990          fragment="NumPy_Fragments")
991   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
992   (PyArrayObject* array=NULL, int is_new_object=0)
993 {
994   npy_intp size[3] = { -1, -1, -1 };
995   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
996                                                    &is_new_object);
997   if (!array || !require_dimensions(array, 3) ||
998       !require_size(array, size, 3)) SWIG_fail;
999   $1 = (DIM_TYPE) array_size(array,0);
1000   $2 = (DIM_TYPE) array_size(array,1);
1001   $3 = (DIM_TYPE) array_size(array,2);
1002   $4 = (DATA_TYPE*) array_data(array);
1003 }
1004 %typemap(freearg)
1005   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
1006 {
1007   if (is_new_object$argnum && array$argnum)
1008     { Py_DECREF(array$argnum); }
1009 }
1010 
1011 /* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1012  *                    DIM_TYPE DIM3)
1013  */
1014 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1015            fragment="NumPy_Macros")
1016   (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1017 {
1018   $1 = is_array($input) || PySequence_Check($input);
1019 }
1020 %typemap(in,
1021          fragment="NumPy_Fragments")
1022   (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1023   (PyArrayObject* array=NULL, int is_new_object=0)
1024 {
1025   npy_intp size[3] = { -1, -1, -1 };
1026   array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
1027                                                 &is_new_object);
1028   if (!array || !require_dimensions(array, 3) ||
1029       !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
1030   $1 = (DATA_TYPE*) array_data(array);
1031   $2 = (DIM_TYPE) array_size(array,0);
1032   $3 = (DIM_TYPE) array_size(array,1);
1033   $4 = (DIM_TYPE) array_size(array,2);
1034 }
1035 %typemap(freearg)
1036   (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1037 {
1038   if (is_new_object$argnum && array$argnum)
1039     { Py_DECREF(array$argnum); }
1040 }
1041 
1042 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1043  *                    DATA_TYPE* IN_FARRAY3)
1044  */
1045 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1046            fragment="NumPy_Macros")
1047   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
1048 {
1049   $1 = is_array($input) || PySequence_Check($input);
1050 }
1051 %typemap(in,
1052          fragment="NumPy_Fragments")
1053   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
1054   (PyArrayObject* array=NULL, int is_new_object=0)
1055 {
1056   npy_intp size[3] = { -1, -1, -1 };
1057   array = obj_to_array_contiguous_allow_conversion($input,
1058                                                    DATA_TYPECODE,
1059                                                    &is_new_object);
1060   if (!array || !require_dimensions(array, 3) ||
1061       !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
1062   $1 = (DIM_TYPE) array_size(array,0);
1063   $2 = (DIM_TYPE) array_size(array,1);
1064   $3 = (DIM_TYPE) array_size(array,2);
1065   $4 = (DATA_TYPE*) array_data(array);
1066 }
1067 %typemap(freearg)
1068   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
1069 {
1070   if (is_new_object$argnum && array$argnum)
1071     { Py_DECREF(array$argnum); }
1072 }
1073 
1074 /* Typemap suite for (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1075  */
1076 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1077            fragment="NumPy_Macros")
1078   (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1079 {
1080   $1 = is_array($input) || PySequence_Check($input);
1081 }
1082 %typemap(in,
1083          fragment="NumPy_Fragments")
1084   (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1085   (PyArrayObject* array=NULL, int is_new_object=0)
1086 {
1087   npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3};
1088   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1089                                                    &is_new_object);
1090   if (!array || !require_dimensions(array, 4) ||
1091       !require_size(array, size, 4)) SWIG_fail;
1092   $1 = ($1_ltype) array_data(array);
1093 }
1094 %typemap(freearg)
1095   (DATA_TYPE IN_ARRAY4[ANY][ANY][ANY][ANY])
1096 {
1097   if (is_new_object$argnum && array$argnum)
1098     { Py_DECREF(array$argnum); }
1099 }
1100 
1101 /* Typemap suite for (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1102  *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1103  */
1104 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1105            fragment="NumPy_Macros")
1106   (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1107 {
1108   $1 = is_array($input) || PySequence_Check($input);
1109 }
1110 %typemap(in,
1111          fragment="NumPy_Fragments")
1112   (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1113   (PyArrayObject* array=NULL, int is_new_object=0)
1114 {
1115   npy_intp size[4] = { -1, -1, -1, -1 };
1116   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1117                                                    &is_new_object);
1118   if (!array || !require_dimensions(array, 4) ||
1119       !require_size(array, size, 4)) SWIG_fail;
1120   $1 = (DATA_TYPE*) array_data(array);
1121   $2 = (DIM_TYPE) array_size(array,0);
1122   $3 = (DIM_TYPE) array_size(array,1);
1123   $4 = (DIM_TYPE) array_size(array,2);
1124   $5 = (DIM_TYPE) array_size(array,3);
1125 }
1126 %typemap(freearg)
1127   (DATA_TYPE* IN_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1128 {
1129   if (is_new_object$argnum && array$argnum)
1130     { Py_DECREF(array$argnum); }
1131 }
1132 
1133 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
1134  *                    DATA_TYPE* IN_ARRAY4)
1135  */
1136 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1137            fragment="NumPy_Macros")
1138   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
1139 {
1140   $1 = is_array($input) || PySequence_Check($input);
1141 }
1142 %typemap(in,
1143          fragment="NumPy_Fragments")
1144   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
1145   (PyArrayObject* array=NULL, int is_new_object=0)
1146 {
1147   npy_intp size[4] = { -1, -1, -1 , -1};
1148   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1149                                                    &is_new_object);
1150   if (!array || !require_dimensions(array, 4) ||
1151       !require_size(array, size, 4)) SWIG_fail;
1152   $1 = (DIM_TYPE) array_size(array,0);
1153   $2 = (DIM_TYPE) array_size(array,1);
1154   $3 = (DIM_TYPE) array_size(array,2);
1155   $4 = (DIM_TYPE) array_size(array,3);
1156   $5 = (DATA_TYPE*) array_data(array);
1157 }
1158 %typemap(freearg)
1159   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_ARRAY4)
1160 {
1161   if (is_new_object$argnum && array$argnum)
1162     { Py_DECREF(array$argnum); }
1163 }
1164 
1165 /* Typemap suite for (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1166  *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1167  */
1168 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1169            fragment="NumPy_Macros")
1170   (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1171 {
1172   $1 = is_array($input) || PySequence_Check($input);
1173 }
1174 %typemap(in,
1175          fragment="NumPy_Fragments")
1176   (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1177   (PyArrayObject* array=NULL, int is_new_object=0)
1178 {
1179   npy_intp size[4] = { -1, -1, -1, -1 };
1180   array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
1181                                                 &is_new_object);
1182   if (!array || !require_dimensions(array, 4) ||
1183       !require_size(array, size, 4) | !require_fortran(array)) SWIG_fail;
1184   $1 = (DATA_TYPE*) array_data(array);
1185   $2 = (DIM_TYPE) array_size(array,0);
1186   $3 = (DIM_TYPE) array_size(array,1);
1187   $4 = (DIM_TYPE) array_size(array,2);
1188   $5 = (DIM_TYPE) array_size(array,3);
1189 }
1190 %typemap(freearg)
1191   (DATA_TYPE* IN_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1192 {
1193   if (is_new_object$argnum && array$argnum)
1194     { Py_DECREF(array$argnum); }
1195 }
1196 
1197 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
1198  *                    DATA_TYPE* IN_FARRAY4)
1199  */
1200 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1201            fragment="NumPy_Macros")
1202   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
1203 {
1204   $1 = is_array($input) || PySequence_Check($input);
1205 }
1206 %typemap(in,
1207          fragment="NumPy_Fragments")
1208   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
1209   (PyArrayObject* array=NULL, int is_new_object=0)
1210 {
1211   npy_intp size[4] = { -1, -1, -1 , -1 };
1212   array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
1213                                                    &is_new_object);
1214   if (!array || !require_dimensions(array, 4) ||
1215       !require_size(array, size, 4) || !require_fortran(array)) SWIG_fail;
1216   $1 = (DIM_TYPE) array_size(array,0);
1217   $2 = (DIM_TYPE) array_size(array,1);
1218   $3 = (DIM_TYPE) array_size(array,2);
1219   $4 = (DIM_TYPE) array_size(array,3);
1220   $5 = (DATA_TYPE*) array_data(array);
1221 }
1222 %typemap(freearg)
1223   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* IN_FARRAY4)
1224 {
1225   if (is_new_object$argnum && array$argnum)
1226     { Py_DECREF(array$argnum); }
1227 }
1228 
1229 /***************************/
1230 /* In-Place Array Typemaps */
1231 /***************************/
1232 
1233 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
1234  */
1235 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1236            fragment="NumPy_Macros")
1237   (DATA_TYPE INPLACE_ARRAY1[ANY])
1238 {
1239   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1240                                                  DATA_TYPECODE);
1241 }
1242 %typemap(in,
1243          fragment="NumPy_Fragments")
1244   (DATA_TYPE INPLACE_ARRAY1[ANY])
1245   (PyArrayObject* array=NULL)
1246 {
1247   npy_intp size[1] = { $1_dim0 };
1248   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1249   if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
1250       !require_contiguous(array) || !require_native(array)) SWIG_fail;
1251   $1 = ($1_ltype) array_data(array);
1252 }
1253 
1254 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
1255  */
1256 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1257            fragment="NumPy_Macros")
1258   (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
1259 {
1260   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1261                                                  DATA_TYPECODE);
1262 }
1263 %typemap(in,
1264          fragment="NumPy_Fragments")
1265   (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
1266   (PyArrayObject* array=NULL, int i=1)
1267 {
1268   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1269   if (!array || !require_dimensions(array,1) || !require_contiguous(array)
1270       || !require_native(array)) SWIG_fail;
1271   $1 = (DATA_TYPE*) array_data(array);
1272   $2 = 1;
1273   for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
1274 }
1275 
1276 /* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1277  */
1278 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1279            fragment="NumPy_Macros")
1280   (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1281 {
1282   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1283                                                  DATA_TYPECODE);
1284 }
1285 %typemap(in,
1286          fragment="NumPy_Fragments")
1287   (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1288   (PyArrayObject* array=NULL, int i=0)
1289 {
1290   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1291   if (!array || !require_dimensions(array,1) || !require_contiguous(array)
1292       || !require_native(array)) SWIG_fail;
1293   $1 = 1;
1294   for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
1295   $2 = (DATA_TYPE*) array_data(array);
1296 }
1297 
1298 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1299  */
1300 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1301            fragment="NumPy_Macros")
1302   (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1303 {
1304   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1305                                                  DATA_TYPECODE);
1306 }
1307 %typemap(in,
1308          fragment="NumPy_Fragments")
1309   (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1310   (PyArrayObject* array=NULL)
1311 {
1312   npy_intp size[2] = { $1_dim0, $1_dim1 };
1313   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1314   if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
1315       !require_contiguous(array) || !require_native(array)) SWIG_fail;
1316   $1 = ($1_ltype) array_data(array);
1317 }
1318 
1319 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1320  */
1321 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1322            fragment="NumPy_Macros")
1323   (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1324 {
1325   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1326                                                  DATA_TYPECODE);
1327 }
1328 %typemap(in,
1329          fragment="NumPy_Fragments")
1330   (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1331   (PyArrayObject* array=NULL)
1332 {
1333   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1334   if (!array || !require_dimensions(array,2) || !require_contiguous(array)
1335       || !require_native(array)) SWIG_fail;
1336   $1 = (DATA_TYPE*) array_data(array);
1337   $2 = (DIM_TYPE) array_size(array,0);
1338   $3 = (DIM_TYPE) array_size(array,1);
1339 }
1340 
1341 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1342  */
1343 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1344            fragment="NumPy_Macros")
1345   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1346 {
1347   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1348                                                  DATA_TYPECODE);
1349 }
1350 %typemap(in,
1351          fragment="NumPy_Fragments")
1352   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1353   (PyArrayObject* array=NULL)
1354 {
1355   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1356   if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
1357       !require_native(array)) SWIG_fail;
1358   $1 = (DIM_TYPE) array_size(array,0);
1359   $2 = (DIM_TYPE) array_size(array,1);
1360   $3 = (DATA_TYPE*) array_data(array);
1361 }
1362 
1363 /* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1364  */
1365 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1366            fragment="NumPy_Macros")
1367   (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1368 {
1369   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1370                                                  DATA_TYPECODE);
1371 }
1372 %typemap(in,
1373          fragment="NumPy_Fragments")
1374   (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1375   (PyArrayObject* array=NULL)
1376 {
1377   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1378   if (!array || !require_dimensions(array,2) || !require_contiguous(array)
1379       || !require_native(array) || !require_fortran(array)) SWIG_fail;
1380   $1 = (DATA_TYPE*) array_data(array);
1381   $2 = (DIM_TYPE) array_size(array,0);
1382   $3 = (DIM_TYPE) array_size(array,1);
1383 }
1384 
1385 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1386  */
1387 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1388            fragment="NumPy_Macros")
1389   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1390 {
1391   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1392                                                  DATA_TYPECODE);
1393 }
1394 %typemap(in,
1395          fragment="NumPy_Fragments")
1396   (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1397   (PyArrayObject* array=NULL)
1398 {
1399   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1400   if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
1401       !require_native(array) || !require_fortran(array)) SWIG_fail;
1402   $1 = (DIM_TYPE) array_size(array,0);
1403   $2 = (DIM_TYPE) array_size(array,1);
1404   $3 = (DATA_TYPE*) array_data(array);
1405 }
1406 
1407 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1408  */
1409 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1410            fragment="NumPy_Macros")
1411   (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1412 {
1413   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1414                                                  DATA_TYPECODE);
1415 }
1416 %typemap(in,
1417          fragment="NumPy_Fragments")
1418   (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1419   (PyArrayObject* array=NULL)
1420 {
1421   npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
1422   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1423   if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
1424       !require_contiguous(array) || !require_native(array)) SWIG_fail;
1425   $1 = ($1_ltype) array_data(array);
1426 }
1427 
1428 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1429  *                    DIM_TYPE DIM3)
1430  */
1431 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1432            fragment="NumPy_Macros")
1433   (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1434 {
1435   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1436                                                  DATA_TYPECODE);
1437 }
1438 %typemap(in,
1439          fragment="NumPy_Fragments")
1440   (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1441   (PyArrayObject* array=NULL)
1442 {
1443   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1444   if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
1445       !require_native(array)) SWIG_fail;
1446   $1 = (DATA_TYPE*) array_data(array);
1447   $2 = (DIM_TYPE) array_size(array,0);
1448   $3 = (DIM_TYPE) array_size(array,1);
1449   $4 = (DIM_TYPE) array_size(array,2);
1450 }
1451 
1452 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1453  *                    DATA_TYPE* INPLACE_ARRAY3)
1454  */
1455 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1456            fragment="NumPy_Macros")
1457   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
1458 {
1459   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1460                                                  DATA_TYPECODE);
1461 }
1462 %typemap(in,
1463          fragment="NumPy_Fragments")
1464   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
1465   (PyArrayObject* array=NULL)
1466 {
1467   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1468   if (!array || !require_dimensions(array,3) || !require_contiguous(array)
1469       || !require_native(array)) SWIG_fail;
1470   $1 = (DIM_TYPE) array_size(array,0);
1471   $2 = (DIM_TYPE) array_size(array,1);
1472   $3 = (DIM_TYPE) array_size(array,2);
1473   $4 = (DATA_TYPE*) array_data(array);
1474 }
1475 
1476 /* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1477  *                    DIM_TYPE DIM3)
1478  */
1479 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1480            fragment="NumPy_Macros")
1481   (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1482 {
1483   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1484                                                  DATA_TYPECODE);
1485 }
1486 %typemap(in,
1487          fragment="NumPy_Fragments")
1488   (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1489   (PyArrayObject* array=NULL)
1490 {
1491   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1492   if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
1493       !require_native(array) || !require_fortran(array)) SWIG_fail;
1494   $1 = (DATA_TYPE*) array_data(array);
1495   $2 = (DIM_TYPE) array_size(array,0);
1496   $3 = (DIM_TYPE) array_size(array,1);
1497   $4 = (DIM_TYPE) array_size(array,2);
1498 }
1499 
1500 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1501  *                    DATA_TYPE* INPLACE_FARRAY3)
1502  */
1503 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1504            fragment="NumPy_Macros")
1505   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
1506 {
1507   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1508                                                  DATA_TYPECODE);
1509 }
1510 %typemap(in,
1511          fragment="NumPy_Fragments")
1512   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
1513   (PyArrayObject* array=NULL)
1514 {
1515   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1516   if (!array || !require_dimensions(array,3) || !require_contiguous(array)
1517       || !require_native(array) || !require_fortran(array)) SWIG_fail;
1518   $1 = (DIM_TYPE) array_size(array,0);
1519   $2 = (DIM_TYPE) array_size(array,1);
1520   $3 = (DIM_TYPE) array_size(array,2);
1521   $4 = (DATA_TYPE*) array_data(array);
1522 }
1523 
1524 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
1525  */
1526 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1527            fragment="NumPy_Macros")
1528   (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
1529 {
1530   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1531                                                  DATA_TYPECODE);
1532 }
1533 %typemap(in,
1534          fragment="NumPy_Fragments")
1535   (DATA_TYPE INPLACE_ARRAY4[ANY][ANY][ANY][ANY])
1536   (PyArrayObject* array=NULL)
1537 {
1538   npy_intp size[4] = { $1_dim0, $1_dim1, $1_dim2 , $1_dim3 };
1539   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1540   if (!array || !require_dimensions(array,4) || !require_size(array, size, 4) ||
1541       !require_contiguous(array) || !require_native(array)) SWIG_fail;
1542   $1 = ($1_ltype) array_data(array);
1543 }
1544 
1545 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1546  *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1547  */
1548 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1549            fragment="NumPy_Macros")
1550   (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1551 {
1552   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1553                                                  DATA_TYPECODE);
1554 }
1555 %typemap(in,
1556          fragment="NumPy_Fragments")
1557   (DATA_TYPE* INPLACE_ARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1558   (PyArrayObject* array=NULL)
1559 {
1560   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1561   if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
1562       !require_native(array)) SWIG_fail;
1563   $1 = (DATA_TYPE*) array_data(array);
1564   $2 = (DIM_TYPE) array_size(array,0);
1565   $3 = (DIM_TYPE) array_size(array,1);
1566   $4 = (DIM_TYPE) array_size(array,2);
1567   $5 = (DIM_TYPE) array_size(array,3);
1568 }
1569 
1570 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4,
1571  *                    DATA_TYPE* INPLACE_ARRAY4)
1572  */
1573 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1574            fragment="NumPy_Macros")
1575   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
1576 {
1577   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1578                                                  DATA_TYPECODE);
1579 }
1580 %typemap(in,
1581          fragment="NumPy_Fragments")
1582   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_ARRAY4)
1583   (PyArrayObject* array=NULL)
1584 {
1585   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1586   if (!array || !require_dimensions(array,4) || !require_contiguous(array)
1587       || !require_native(array)) SWIG_fail;
1588   $1 = (DIM_TYPE) array_size(array,0);
1589   $2 = (DIM_TYPE) array_size(array,1);
1590   $3 = (DIM_TYPE) array_size(array,2);
1591   $4 = (DIM_TYPE) array_size(array,3);
1592   $5 = (DATA_TYPE*) array_data(array);
1593 }
1594 
1595 /* Typemap suite for (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2,
1596  *                    DIM_TYPE DIM3, DIM_TYPE DIM4)
1597  */
1598 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1599            fragment="NumPy_Macros")
1600   (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1601 {
1602   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1603                                                  DATA_TYPECODE);
1604 }
1605 %typemap(in,
1606          fragment="NumPy_Fragments")
1607   (DATA_TYPE* INPLACE_FARRAY4, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4)
1608   (PyArrayObject* array=NULL)
1609 {
1610   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1611   if (!array || !require_dimensions(array,4) || !require_contiguous(array) ||
1612       !require_native(array) || !require_fortran(array)) SWIG_fail;
1613   $1 = (DATA_TYPE*) array_data(array);
1614   $2 = (DIM_TYPE) array_size(array,0);
1615   $3 = (DIM_TYPE) array_size(array,1);
1616   $4 = (DIM_TYPE) array_size(array,2);
1617   $5 = (DIM_TYPE) array_size(array,3);
1618 }
1619 
1620 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1621  *                    DATA_TYPE* INPLACE_FARRAY4)
1622  */
1623 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1624            fragment="NumPy_Macros")
1625   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
1626 {
1627   $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1628                                                  DATA_TYPECODE);
1629 }
1630 %typemap(in,
1631          fragment="NumPy_Fragments")
1632   (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DIM_TYPE DIM4, DATA_TYPE* INPLACE_FARRAY4)
1633   (PyArrayObject* array=NULL)
1634 {
1635   array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1636   if (!array || !require_dimensions(array,4) || !require_contiguous(array)
1637       || !require_native(array) || !require_fortran(array)) SWIG_fail;
1638   $1 = (DIM_TYPE) array_size(array,0);
1639   $2 = (DIM_TYPE) array_size(array,1);
1640   $3 = (DIM_TYPE) array_size(array,2);
1641   $4 = (DIM_TYPE) array_size(array,3);
1642   $5 = (DATA_TYPE*) array_data(array);
1643 }
1644 
1645 /*************************/
1646 /* Argout Array Typemaps */
1647 /*************************/
1648 
1649 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
1650  */
1651 %typemap(in,numinputs=0,
1652          fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1653   (DATA_TYPE ARGOUT_ARRAY1[ANY])
1654   (PyObject* array = NULL)
1655 {
1656   npy_intp dims[1] = { $1_dim0 };
1657   array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1658   if (!array) SWIG_fail;
1659   $1 = ($1_ltype) array_data(array);
1660 }
1661 %typemap(argout)
1662   (DATA_TYPE ARGOUT_ARRAY1[ANY])
1663 {
1664   $result = SWIG_Python_AppendOutput($result,array$argnum);
1665 }
1666 
1667 /* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1668  */
1669 %typemap(in,numinputs=1,
1670          fragment="NumPy_Fragments")
1671   (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1672   (PyObject* array = NULL)
1673 {
1674   npy_intp dims[1];
1675   if (!PyInt_Check($input))
1676   {
1677     const char* typestring = pytype_string($input);
1678     PyErr_Format(PyExc_TypeError,
1679                  "Int dimension expected.  '%s' given.",
1680                  typestring);
1681     SWIG_fail;
1682   }
1683   $2 = (DIM_TYPE) PyInt_AsLong($input);
1684   dims[0] = (npy_intp) $2;
1685   array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1686   if (!array) SWIG_fail;
1687   $1 = (DATA_TYPE*) array_data(array);
1688 }
1689 %typemap(argout)
1690   (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1691 {
1692   $result = SWIG_Python_AppendOutput($result,array$argnum);
1693 }
1694 
1695 /* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
1696  */
1697 %typemap(in,numinputs=1,
1698          fragment="NumPy_Fragments")
1699   (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
1700   (PyObject* array = NULL)
1701 {
1702   npy_intp dims[1];
1703   if (!PyInt_Check($input))
1704   {
1705     const char* typestring = pytype_string($input);
1706     PyErr_Format(PyExc_TypeError,
1707                  "Int dimension expected.  '%s' given.",
1708                  typestring);
1709     SWIG_fail;
1710   }
1711   $1 = (DIM_TYPE) PyInt_AsLong($input);
1712   dims[0] = (npy_intp) $1;
1713   array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1714   if (!array) SWIG_fail;
1715   $2 = (DATA_TYPE*) array_data(array);
1716 }
1717 %typemap(argout)
1718   (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
1719 {
1720   $result = SWIG_Python_AppendOutput($result,array$argnum);
1721 }
1722 
1723 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
1724  */
1725 %typemap(in,numinputs=0,
1726          fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1727   (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
1728   (PyObject* array = NULL)
1729 {
1730   npy_intp dims[2] = { $1_dim0, $1_dim1 };
1731   array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
1732   if (!array) SWIG_fail;
1733   $1 = ($1_ltype) array_data(array);
1734 }
1735 %typemap(argout)
1736   (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
1737 {
1738   $result = SWIG_Python_AppendOutput($result,array$argnum);
1739 }
1740 
1741 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
1742  */
1743 %typemap(in,numinputs=0,
1744          fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1745   (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
1746   (PyObject* array = NULL)
1747 {
1748   npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
1749   array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
1750   if (!array) SWIG_fail;
1751   $1 = ($1_ltype) array_data(array);
1752 }
1753 %typemap(argout)
1754   (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
1755 {
1756   $result = SWIG_Python_AppendOutput($result,array$argnum);
1757 }
1758 
1759 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
1760  */
1761 %typemap(in,numinputs=0,
1762          fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1763   (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
1764   (PyObject * array = NULL)
1765 {
1766   npy_intp dims[4] = { $1_dim0, $1_dim1, $1_dim2, $1_dim3 };
1767   array = PyArray_SimpleNew(4, dims, DATA_TYPECODE);
1768   if (!array) SWIG_fail;
1769   $1 = ($1_ltype) array_data(array);
1770 }
1771 %typemap(argout)
1772   (DATA_TYPE ARGOUT_ARRAY4[ANY][ANY][ANY][ANY])
1773 {
1774   $result = SWIG_Python_AppendOutput($result,array$argnum);
1775 }
1776 
1777 /*****************************/
1778 /* Argoutview Array Typemaps */
1779 /*****************************/
1780 
1781 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
1782  */
1783 %typemap(in,numinputs=0)
1784   (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1    )
1785   (DATA_TYPE*  data_temp = NULL , DIM_TYPE  dim_temp)
1786 {
1787   $1 = &data_temp;
1788   $2 = &dim_temp;
1789 }
1790 %typemap(argout,
1791          fragment="NumPy_Backward_Compatibility")
1792   (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
1793 {
1794   npy_intp dims[1] = { *$2 };
1795   PyObject* array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
1796   if (!array) SWIG_fail;
1797   $result = SWIG_Python_AppendOutput($result,array);
1798 }
1799 
1800 /* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
1801  */
1802 %typemap(in,numinputs=0)
1803   (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEW_ARRAY1)
1804   (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp = NULL )
1805 {
1806   $1 = &dim_temp;
1807   $2 = &data_temp;
1808 }
1809 %typemap(argout,
1810          fragment="NumPy_Backward_Compatibility")
1811   (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
1812 {
1813   npy_intp dims[1] = { *$1 };
1814   PyObject* array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
1815   if (!array) SWIG_fail;
1816   $result = SWIG_Python_AppendOutput($result,array);
1817 }
1818 
1819 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1820  */
1821 %typemap(in,numinputs=0)
1822   (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
1823   (DATA_TYPE*  data_temp = NULL , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
1824 {
1825   $1 = &data_temp;
1826   $2 = &dim1_temp;
1827   $3 = &dim2_temp;
1828 }
1829 %typemap(argout,
1830          fragment="NumPy_Backward_Compatibility")
1831   (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1832 {
1833   npy_intp dims[2] = { *$2, *$3 };
1834   PyObject* array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
1835   if (!array) SWIG_fail;
1836   $result = SWIG_Python_AppendOutput($result,array);
1837 }
1838 
1839 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
1840  */
1841 %typemap(in,numinputs=0)
1842   (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_ARRAY2)
1843   (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL )
1844 {
1845   $1 = &dim1_temp;
1846   $2 = &dim2_temp;
1847   $3 = &data_temp;
1848 }
1849 %typemap(argout,
1850          fragment="NumPy_Backward_Compatibility")
1851   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
1852 {
1853   npy_intp dims[2] = { *$1, *$2 };
1854   PyObject* array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
1855   if (!array) SWIG_fail;
1856   $result = SWIG_Python_AppendOutput($result,array);
1857 }
1858 
1859 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1860  */
1861 %typemap(in,numinputs=0)
1862   (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
1863   (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
1864 {
1865   $1 = &data_temp;
1866   $2 = &dim1_temp;
1867   $3 = &dim2_temp;
1868 }
1869 %typemap(argout,
1870          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1871   (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1872 {
1873   npy_intp dims[2] = { *$2, *$3 };
1874   PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
1875   PyArrayObject* array = (PyArrayObject*) obj;
1876   if (!array || !require_fortran(array)) SWIG_fail;
1877   $result = SWIG_Python_AppendOutput($result,obj);
1878 }
1879 
1880 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
1881  */
1882 %typemap(in,numinputs=0)
1883   (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_FARRAY2)
1884   (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL  )
1885 {
1886   $1 = &dim1_temp;
1887   $2 = &dim2_temp;
1888   $3 = &data_temp;
1889 }
1890 %typemap(argout,
1891          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1892   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
1893 {
1894   npy_intp dims[2] = { *$1, *$2 };
1895   PyObject* obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
1896   PyArrayObject* array = (PyArrayObject*) obj;
1897   if (!array || !require_fortran(array)) SWIG_fail;
1898   $result = SWIG_Python_AppendOutput($result,obj);
1899 }
1900 
1901 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
1902                       DIM_TYPE* DIM3)
1903  */
1904 %typemap(in,numinputs=0)
1905   (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
1906   (DATA_TYPE* data_temp = NULL  , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
1907 {
1908   $1 = &data_temp;
1909   $2 = &dim1_temp;
1910   $3 = &dim2_temp;
1911   $4 = &dim3_temp;
1912 }
1913 %typemap(argout,
1914          fragment="NumPy_Backward_Compatibility")
1915   (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
1916 {
1917   npy_intp dims[3] = { *$2, *$3, *$4 };
1918   PyObject* array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
1919   if (!array) SWIG_fail;
1920   $result = SWIG_Python_AppendOutput($result,array);
1921 }
1922 
1923 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
1924                       DATA_TYPE** ARGOUTVIEW_ARRAY3)
1925  */
1926 %typemap(in,numinputs=0)
1927   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
1928   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL)
1929 {
1930   $1 = &dim1_temp;
1931   $2 = &dim2_temp;
1932   $3 = &dim3_temp;
1933   $4 = &data_temp;
1934 }
1935 %typemap(argout,
1936          fragment="NumPy_Backward_Compatibility")
1937   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
1938 {
1939   npy_intp dims[3] = { *$1, *$2, *$3 };
1940   PyObject* array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
1941   if (!array) SWIG_fail;
1942   $result = SWIG_Python_AppendOutput($result,array);
1943 }
1944 
1945 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
1946                       DIM_TYPE* DIM3)
1947  */
1948 %typemap(in,numinputs=0)
1949   (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
1950   (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
1951 {
1952   $1 = &data_temp;
1953   $2 = &dim1_temp;
1954   $3 = &dim2_temp;
1955   $4 = &dim3_temp;
1956 }
1957 %typemap(argout,
1958          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1959   (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
1960 {
1961   npy_intp dims[3] = { *$2, *$3, *$4 };
1962   PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
1963   PyArrayObject* array = (PyArrayObject*) obj;
1964   if (!array || require_fortran(array)) SWIG_fail;
1965   $result = SWIG_Python_AppendOutput($result,obj);
1966 }
1967 
1968 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
1969                       DATA_TYPE** ARGOUTVIEW_FARRAY3)
1970  */
1971 %typemap(in,numinputs=0)
1972   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEW_FARRAY3)
1973   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL   )
1974 {
1975   $1 = &dim1_temp;
1976   $2 = &dim2_temp;
1977   $3 = &dim3_temp;
1978   $4 = &data_temp;
1979 }
1980 %typemap(argout,
1981          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1982   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
1983 {
1984   npy_intp dims[3] = { *$1, *$2, *$3 };
1985   PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
1986   PyArrayObject* array = (PyArrayObject*) obj;
1987   if (!array || require_fortran(array)) SWIG_fail;
1988   $result = SWIG_Python_AppendOutput($result,obj);
1989 }
1990 
1991 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
1992                       DIM_TYPE* DIM3, DIM_TYPE* DIM4)
1993  */
1994 %typemap(in,numinputs=0)
1995   (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
1996   (DATA_TYPE* data_temp = NULL  , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
1997 {
1998   data_temp = NULL;
1999   $1 = &data_temp;
2000   $2 = &dim1_temp;
2001   $3 = &dim2_temp;
2002   $4 = &dim3_temp;
2003   $5 = &dim4_temp;
2004 }
2005 %typemap(argout,
2006          fragment="NumPy_Backward_Compatibility")
2007   (DATA_TYPE** ARGOUTVIEW_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2008 {
2009   npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2010   PyObject * array = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2011   if (!array) SWIG_fail;
2012   $result = SWIG_Python_AppendOutput($result,array);
2013 }
2014 
2015 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2016                       DATA_TYPE** ARGOUTVIEW_ARRAY4)
2017  */
2018 %typemap(in,numinputs=0)
2019   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEW_ARRAY4)
2020   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL  )
2021 {
2022   data_temp = NULL;
2023   $1 = &dim1_temp;
2024   $2 = &dim2_temp;
2025   $3 = &dim3_temp;
2026   $4 = &dim4_temp;
2027   $5 = &data_temp;
2028 }
2029 %typemap(argout,
2030          fragment="NumPy_Backward_Compatibility")
2031   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_ARRAY4)
2032 {
2033   npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2034   PyObject * array = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2035   if (!array) SWIG_fail;
2036   $result = SWIG_Python_AppendOutput($result,array);
2037 }
2038 
2039 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2040                       DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2041  */
2042 %typemap(in,numinputs=0)
2043   (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2044   (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2045 {
2046   data_temp = NULL;
2047   $1 = &data_temp;
2048   $2 = &dim1_temp;
2049   $3 = &dim2_temp;
2050   $4 = &dim3_temp;
2051   $5 = &dim4_temp;
2052 }
2053 %typemap(argout,
2054          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2055   (DATA_TYPE** ARGOUTVIEW_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2056 {
2057   npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2058   PyObject * obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2059   PyArrayObject * array = (PyArrayObject*) obj;
2060   if (!array || require_fortran(array)) SWIG_fail;
2061   $result = SWIG_Python_AppendOutput($result,obj);
2062 }
2063 
2064 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2065                       DATA_TYPE** ARGOUTVIEW_FARRAY4)
2066  */
2067 %typemap(in,numinputs=0)
2068   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEW_FARRAY4)
2069   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
2070 {
2071   data_temp = NULL;
2072   $1 = &dim1_temp;
2073   $2 = &dim2_temp;
2074   $3 = &dim3_temp;
2075   $4 = &dim4_temp;
2076   $5 = &data_temp;
2077 }
2078 %typemap(argout,
2079          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2080   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEW_FARRAY4)
2081 {
2082   npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2083   PyObject * obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2084   PyArrayObject * array = (PyArrayObject*) obj;
2085   if (!array || require_fortran(array)) SWIG_fail;
2086   $result = SWIG_Python_AppendOutput($result,obj);
2087 }
2088 
2089 /*************************************/
2090 /* Managed Argoutview Array Typemaps */
2091 /*************************************/
2092 
2093 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
2094  */
2095 %typemap(in,numinputs=0)
2096   (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1    )
2097   (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim_temp)
2098 {
2099   data_temp = NULL;
2100   $1 = &data_temp;
2101   $2 = &dim_temp;
2102 }
2103 %typemap(argout,
2104          fragment="NumPy_Backward_Compatibility")
2105   (DATA_TYPE** ARGOUTVIEWM_ARRAY1, DIM_TYPE* DIM1)
2106 {
2107   npy_intp dims[1] = { *$2 };
2108   PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
2109 
2110   if (!array) SWIG_fail;
2111 
2112   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2113 
2114   $result = SWIG_Python_AppendOutput($result,array);
2115 }
2116 
2117 /* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
2118  */
2119 %typemap(in,numinputs=0)
2120   (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEWM_ARRAY1)
2121   (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp = NULL  )
2122 {
2123   data_temp = NULL;
2124   $1 = &dim_temp;
2125   $2 = &data_temp;
2126 }
2127 %typemap(argout,
2128          fragment="NumPy_Backward_Compatibility")
2129   (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEWM_ARRAY1)
2130 {
2131   npy_intp dims[1] = { *$1 };
2132   PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
2133 
2134   if (!array) SWIG_fail;
2135 
2136   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2137 
2138   $result = SWIG_Python_AppendOutput($result,array);
2139 }
2140 
2141 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2142  */
2143 %typemap(in,numinputs=0)
2144   (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
2145   (DATA_TYPE*  data_temp = NULL  , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
2146 {
2147   data_temp = NULL;
2148   $1 = &data_temp;
2149   $2 = &dim1_temp;
2150   $3 = &dim2_temp;
2151 }
2152 %typemap(argout,
2153          fragment="NumPy_Backward_Compatibility")
2154   (DATA_TYPE** ARGOUTVIEWM_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2155 {
2156   npy_intp dims[2] = { *$2, *$3 };
2157   PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
2158 
2159   if (!array) SWIG_fail;
2160 
2161   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2162 
2163   $result = SWIG_Python_AppendOutput($result,array);
2164 }
2165 
2166 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_ARRAY2)
2167  */
2168 %typemap(in,numinputs=0)
2169   (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEWM_ARRAY2)
2170   (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL  )
2171 {
2172   data_temp = NULL;
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** ARGOUTVIEWM_ARRAY2)
2180 {
2181   npy_intp dims[2] = { *$1, *$2 };
2182   PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
2183 
2184   if (!array) SWIG_fail;
2185 
2186   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2187 
2188   $result = SWIG_Python_AppendOutput($result,array);
2189 }
2190 
2191 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2192  */
2193 %typemap(in,numinputs=0)
2194   (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
2195   (DATA_TYPE*  data_temp = NULL   , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
2196 {
2197   data_temp = NULL;
2198   $1 = &data_temp;
2199   $2 = &dim1_temp;
2200   $3 = &dim2_temp;
2201 }
2202 %typemap(argout,
2203          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2204   (DATA_TYPE** ARGOUTVIEWM_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
2205 {
2206   npy_intp dims[2] = { *$2, *$3 };
2207   PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
2208   PyArrayObject * array = (PyArrayObject*) obj;
2209 
2210   if (!array || !require_fortran(array)) SWIG_fail;
2211 
2212   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2213 
2214   $result = SWIG_Python_AppendOutput($result,obj);
2215 }
2216 
2217 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
2218  */
2219 %typemap(in,numinputs=0)
2220   (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEWM_FARRAY2)
2221   (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp = NULL   )
2222 {
2223   data_temp = NULL;
2224   $1 = &dim1_temp;
2225   $2 = &dim2_temp;
2226   $3 = &data_temp;
2227 }
2228 %typemap(argout,
2229          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2230   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEWM_FARRAY2)
2231 {
2232   npy_intp dims[2] = { *$1, *$2 };
2233   PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
2234   PyArrayObject * array = (PyArrayObject*) obj;
2235 
2236   if (!array || !require_fortran(array)) SWIG_fail;
2237 
2238   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2239 
2240   $result = SWIG_Python_AppendOutput($result,obj);
2241 }
2242 
2243 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2244                       DIM_TYPE* DIM3)
2245  */
2246 %typemap(in,numinputs=0)
2247   (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
2248   (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
2249 {
2250   data_temp = NULL;
2251   $1 = &data_temp;
2252   $2 = &dim1_temp;
2253   $3 = &dim2_temp;
2254   $4 = &dim3_temp;
2255 }
2256 %typemap(argout,
2257          fragment="NumPy_Backward_Compatibility")
2258   (DATA_TYPE** ARGOUTVIEWM_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2259 {
2260   npy_intp dims[3] = { *$2, *$3, *$4 };
2261   PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
2262 
2263   if (!array) SWIG_fail;
2264 
2265   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2266 
2267   $result = SWIG_Python_AppendOutput($result,array);
2268 }
2269 
2270 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
2271                       DATA_TYPE** ARGOUTVIEWM_ARRAY3)
2272  */
2273 %typemap(in,numinputs=0)
2274   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEWM_ARRAY3)
2275   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL   )
2276 {
2277   data_temp = NULL;
2278   $1 = &dim1_temp;
2279   $2 = &dim2_temp;
2280   $3 = &dim3_temp;
2281   $4 = &data_temp;
2282 }
2283 %typemap(argout,
2284          fragment="NumPy_Backward_Compatibility")
2285   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_ARRAY3)
2286 {
2287   npy_intp dims[3] = { *$1, *$2, *$3 };
2288   PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
2289 
2290   if (!array) SWIG_fail;
2291 
2292   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2293 
2294   $result = SWIG_Python_AppendOutput($result,array);
2295 }
2296 
2297 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2298                       DIM_TYPE* DIM3)
2299  */
2300 %typemap(in,numinputs=0)
2301   (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    )
2302   (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
2303 {
2304   data_temp = NULL;
2305   $1 = &data_temp;
2306   $2 = &dim1_temp;
2307   $3 = &dim2_temp;
2308   $4 = &dim3_temp;
2309 }
2310 %typemap(argout,
2311          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2312   (DATA_TYPE** ARGOUTVIEWM_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2313 {
2314   npy_intp dims[3] = { *$2, *$3, *$4 };
2315   PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
2316   PyArrayObject * array = (PyArrayObject*) obj;
2317 
2318   if (!array || require_fortran(array)) SWIG_fail;
2319 
2320   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2321 
2322   $result = SWIG_Python_AppendOutput($result,obj);
2323 }
2324 
2325 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
2326                       DATA_TYPE** ARGOUTVIEWM_FARRAY3)
2327  */
2328 %typemap(in,numinputs=0)
2329   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DATA_TYPE** ARGOUTVIEWM_FARRAY3)
2330   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp = NULL    )
2331 {
2332   data_temp = NULL;
2333   $1 = &dim1_temp;
2334   $2 = &dim2_temp;
2335   $3 = &dim3_temp;
2336   $4 = &data_temp;
2337 }
2338 %typemap(argout,
2339          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2340   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEWM_FARRAY3)
2341 {
2342   npy_intp dims[3] = { *$1, *$2, *$3 };
2343   PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$4));
2344 
2345   PyArrayObject * array = (PyArrayObject*) obj;
2346   if (!array || require_fortran(array)) SWIG_fail;
2347 
2348   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2349 
2350   $result = SWIG_Python_AppendOutput($result,obj);
2351 }
2352 
2353 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2354                       DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2355  */
2356 %typemap(in,numinputs=0)
2357   (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2358   (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2359 {
2360   data_temp = NULL;
2361   $1 = &data_temp;
2362   $2 = &dim1_temp;
2363   $3 = &dim2_temp;
2364   $4 = &dim3_temp;
2365   $5 = &dim4_temp;
2366 }
2367 %typemap(argout,
2368          fragment="NumPy_Backward_Compatibility")
2369   (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2370 {
2371   npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2372   PyObject * array = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2373 
2374   if (!array) SWIG_fail;
2375 
2376   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2377 
2378   $result = SWIG_Python_AppendOutput($result,array);
2379 }
2380 
2381 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2382                       DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2383  */
2384 %typemap(in,numinputs=0)
2385   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2386   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
2387 {
2388   data_temp = NULL;
2389   $1 = &dim1_temp;
2390   $2 = &dim2_temp;
2391   $3 = &dim3_temp;
2392   $4 = &dim4_temp;
2393   $5 = &data_temp;
2394 }
2395 %typemap(argout,
2396          fragment="NumPy_Backward_Compatibility")
2397   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2398 {
2399   npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2400   PyObject * array = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2401 
2402   if (!array) SWIG_fail;
2403 
2404   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2405 
2406   $result = SWIG_Python_AppendOutput($result,array);
2407 }
2408 
2409 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2410                       DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2411  */
2412 %typemap(in,numinputs=0)
2413   (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2414   (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2415 {
2416   data_temp = NULL;
2417   $1 = &data_temp;
2418   $2 = &dim1_temp;
2419   $3 = &dim2_temp;
2420   $4 = &dim3_temp;
2421   $5 = &dim4_temp;
2422 }
2423 %typemap(argout,
2424          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2425   (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
2426 {
2427   npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2428   PyObject * obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2429   PyArrayObject * array = (PyArrayObject*) obj;
2430 
2431   if (!array || require_fortran(array)) SWIG_fail;
2432 
2433   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2434 
2435   $result = SWIG_Python_AppendOutput($result,obj);
2436 }
2437 
2438 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2439                       DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2440  */
2441 %typemap(in,numinputs=0)
2442   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2443   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL    )
2444 {
2445   data_temp = NULL;
2446   $1 = &dim1_temp;
2447   $2 = &dim2_temp;
2448   $3 = &dim3_temp;
2449   $4 = &dim4_temp;
2450   $5 = &data_temp;
2451 }
2452 %typemap(argout,
2453          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2454   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2455 {
2456   npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2457   PyObject * obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2458 
2459   PyArrayObject * array = (PyArrayObject*) obj;
2460   if (!array || require_fortran(array)) SWIG_fail;
2461 
2462   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2463 
2464   $result = SWIG_Python_AppendOutput($result,obj);
2465 }
2466 
2467 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2468                       DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2469  */
2470 %typemap(in,numinputs=0)
2471   (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2472   (DATA_TYPE* data_temp = NULL   , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2473 {
2474   data_temp = NULL;
2475   $1 = &data_temp;
2476   $2 = &dim1_temp;
2477   $3 = &dim2_temp;
2478   $4 = &dim3_temp;
2479   $5 = &dim4_temp;
2480 }
2481 %typemap(argout,
2482          fragment="NumPy_Backward_Compatibility")
2483   (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2484 {
2485   npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2486   PyObject * array = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2487 
2488   if (!array) SWIG_fail;
2489 
2490   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2491 
2492   $result = SWIG_Python_AppendOutput($result,array);
2493 }
2494 
2495 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2496                       DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2497  */
2498 %typemap(in,numinputs=0)
2499   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2500   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL   )
2501 {
2502   data_temp = NULL;
2503   $1 = &dim1_temp;
2504   $2 = &dim2_temp;
2505   $3 = &dim3_temp;
2506   $4 = &dim4_temp;
2507   $5 = &data_temp;
2508 }
2509 %typemap(argout,
2510          fragment="NumPy_Backward_Compatibility")
2511   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4)
2512 {
2513   npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2514   PyObject * array = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2515 
2516   if (!array) SWIG_fail;
2517 
2518   PyArray_BASE(array) = PyCObject_FromVoidPtr((void*)(*$1), free);
2519 
2520   $result = SWIG_Python_AppendOutput($result,array);
2521 }
2522 
2523 /* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
2524                       DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2525  */
2526 %typemap(in,numinputs=0)
2527   (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    )
2528   (DATA_TYPE* data_temp = NULL    , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp)
2529 {
2530   data_temp = NULL;
2531   $1 = &data_temp;
2532   $2 = &dim1_temp;
2533   $3 = &dim2_temp;
2534   $4 = &dim3_temp;
2535   $5 = &dim4_temp;
2536 }
2537 %typemap(argout,
2538          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2539   (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4)
2540 {
2541   npy_intp dims[4] = { *$2, *$3, *$4 , *$5 };
2542   PyObject * obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1));
2543   PyArrayObject * array = (PyArrayObject*) obj;
2544 
2545   if (!array || require_fortran(array)) SWIG_fail;
2546 
2547   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2548 
2549   $result = SWIG_Python_AppendOutput($result,obj);
2550 }
2551 
2552 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4,
2553                       DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2554  */
2555 %typemap(in,numinputs=0)
2556   (DIM_TYPE* DIM1    , DIM_TYPE* DIM2    , DIM_TYPE* DIM3    , DIM_TYPE* DIM4    , DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2557   (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL    )
2558 {
2559   data_temp = NULL;
2560   $1 = &dim1_temp;
2561   $2 = &dim2_temp;
2562   $3 = &dim3_temp;
2563   $4 = &dim4_temp;
2564   $5 = &data_temp;
2565 }
2566 %typemap(argout,
2567          fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
2568   (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4)
2569 {
2570   npy_intp dims[4] = { *$1, *$2, *$3 , *$4 };
2571   PyObject * obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5));
2572 
2573   PyArrayObject * array = (PyArrayObject*) obj;
2574   if (!array || require_fortran(array)) SWIG_fail;
2575 
2576   PyArray_BASE(obj) = PyCObject_FromVoidPtr((void*)(*$1), free);
2577 
2578   $result = SWIG_Python_AppendOutput($result,obj);
2579 }
2580 
2581 %enddef    /* %numpy_typemaps() macro */
2582 /* *************************************************************** */
2583 
2584 /* Concrete instances of the %numpy_typemaps() macro: Each invocation
2585  * below applies all of the typemaps above to the specified data type.
2586  */
2587 %numpy_typemaps(signed char       , NPY_BYTE     , int)
2588 %numpy_typemaps(unsigned char     , NPY_UBYTE    , int)
2589 %numpy_typemaps(short             , NPY_SHORT    , int)
2590 %numpy_typemaps(unsigned short    , NPY_USHORT   , int)
2591 %numpy_typemaps(int               , NPY_INT      , int)
2592 %numpy_typemaps(unsigned int      , NPY_UINT     , int)
2593 %numpy_typemaps(long              , NPY_LONG     , int)
2594 %numpy_typemaps(unsigned long     , NPY_ULONG    , int)
2595 %numpy_typemaps(long long         , NPY_LONGLONG , int)
2596 %numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
2597 %numpy_typemaps(float             , NPY_FLOAT    , int)
2598 %numpy_typemaps(double            , NPY_DOUBLE   , int)
2599 
2600 /* ***************************************************************
2601  * The follow macro expansion does not work, because C++ bool is 4
2602  * bytes and NPY_BOOL is 1 byte
2603  *
2604  *    %numpy_typemaps(bool, NPY_BOOL, int)
2605  */
2606 
2607 /* ***************************************************************
2608  * On my Mac, I get the following warning for this macro expansion:
2609  * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
2610  *
2611  *    %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
2612  */
2613 
2614 /* ***************************************************************
2615  * Swig complains about a syntax error for the following macro
2616  * expansions:
2617  *
2618  *    %numpy_typemaps(complex float,  NPY_CFLOAT , int)
2619  *
2620  *    %numpy_typemaps(complex double, NPY_CDOUBLE, int)
2621  *
2622  *    %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
2623  */
2624 
2625 #endif /* SWIGPYTHON */
2626