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