1 /* -*- C -*- (not really, but good for syntax highlighting) */
4 Copyright (c) 2005-2009, NumPy Developers.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
11 * Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above
15 copyright notice, this list of conditions and the following
16 disclaimer in the documentation and/or other materials provided
17 with the distribution.
19 * Neither the name of the NumPy Developers nor the names of any
20 contributors may be used to endorse or promote products derived
21 from this software without specific prior written permission.
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #ifndef SWIG_FILE_WITH_INIT
40 # define NO_IMPORT_ARRAY
43 #include <numpy/arrayobject.h>
46 /**********************************************************************/
48 %fragment("NumPy_Backward_Compatibility", "header")
50 /* Support older NumPy data type names
52 %#if NDARRAY_VERSION < 0x01000000
53 %#define NPY_BOOL PyArray_BOOL
54 %#define NPY_BYTE PyArray_BYTE
55 %#define NPY_UBYTE PyArray_UBYTE
56 %#define NPY_SHORT PyArray_SHORT
57 %#define NPY_USHORT PyArray_USHORT
58 %#define NPY_INT PyArray_INT
59 %#define NPY_UINT PyArray_UINT
60 %#define NPY_LONG PyArray_LONG
61 %#define NPY_ULONG PyArray_ULONG
62 %#define NPY_LONGLONG PyArray_LONGLONG
63 %#define NPY_ULONGLONG PyArray_ULONGLONG
64 %#define NPY_FLOAT PyArray_FLOAT
65 %#define NPY_DOUBLE PyArray_DOUBLE
66 %#define NPY_LONGDOUBLE PyArray_LONGDOUBLE
67 %#define NPY_CFLOAT PyArray_CFLOAT
68 %#define NPY_CDOUBLE PyArray_CDOUBLE
69 %#define NPY_CLONGDOUBLE PyArray_CLONGDOUBLE
70 %#define NPY_OBJECT PyArray_OBJECT
71 %#define NPY_STRING PyArray_STRING
72 %#define NPY_UNICODE PyArray_UNICODE
73 %#define NPY_VOID PyArray_VOID
74 %#define NPY_NTYPES PyArray_NTYPES
75 %#define NPY_NOTYPE PyArray_NOTYPE
76 %#define NPY_CHAR PyArray_CHAR
77 %#define NPY_USERDEF PyArray_USERDEF
78 %#define npy_intp intp
80 %#define NPY_MAX_BYTE MAX_BYTE
81 %#define NPY_MIN_BYTE MIN_BYTE
82 %#define NPY_MAX_UBYTE MAX_UBYTE
83 %#define NPY_MAX_SHORT MAX_SHORT
84 %#define NPY_MIN_SHORT MIN_SHORT
85 %#define NPY_MAX_USHORT MAX_USHORT
86 %#define NPY_MAX_INT MAX_INT
87 %#define NPY_MIN_INT MIN_INT
88 %#define NPY_MAX_UINT MAX_UINT
89 %#define NPY_MAX_LONG MAX_LONG
90 %#define NPY_MIN_LONG MIN_LONG
91 %#define NPY_MAX_ULONG MAX_ULONG
92 %#define NPY_MAX_LONGLONG MAX_LONGLONG
93 %#define NPY_MIN_LONGLONG MIN_LONGLONG
94 %#define NPY_MAX_ULONGLONG MAX_ULONGLONG
95 %#define NPY_MAX_INTP MAX_INTP
96 %#define NPY_MIN_INTP MIN_INTP
98 %#define NPY_FARRAY FARRAY
99 %#define NPY_F_CONTIGUOUS F_CONTIGUOUS
103 /**********************************************************************/
105 /* The following code originally appeared in
106 * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was
107 * translated from C++ to C by John Hunter. Bill Spotz has modified
108 * it to fix some minor bugs, upgrade from Numeric to numpy (all
109 * versions), add some comments and functionality, and convert from
110 * direct code insertion to SWIG fragments.
113 %fragment("NumPy_Macros", "header")
115 /* Macros to extract array attributes.
117 %#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a))
118 %#define array_type(a) (int)(PyArray_TYPE(a))
119 %#define array_numdims(a) (((PyArrayObject *)a)->nd)
120 %#define array_dimensions(a) (((PyArrayObject *)a)->dimensions)
121 %#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i])
122 %#define array_data(a) (((PyArrayObject *)a)->data)
123 %#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
124 %#define array_is_native(a) (PyArray_ISNOTSWAPPED(a))
125 %#define array_is_fortran(a) (PyArray_ISFORTRAN(a))
128 /**********************************************************************/
130 %fragment("NumPy_Utilities", "header")
132 /* Given a PyObject, return a string describing its type.
134 char* pytype_string(PyObject* py_obj) {
135 if (py_obj == NULL ) return "C NULL value";
136 if (py_obj == Py_None ) return "Python None" ;
137 if (PyCallable_Check(py_obj)) return "callable" ;
138 if (PyString_Check( py_obj)) return "string" ;
139 if (PyInt_Check( py_obj)) return "int" ;
140 if (PyFloat_Check( py_obj)) return "float" ;
141 if (PyDict_Check( py_obj)) return "dict" ;
142 if (PyList_Check( py_obj)) return "list" ;
143 if (PyTuple_Check( py_obj)) return "tuple" ;
144 if (PyFile_Check( py_obj)) return "file" ;
145 if (PyModule_Check( py_obj)) return "module" ;
146 if (PyInstance_Check(py_obj)) return "instance" ;
148 return "unkown type";
151 /* Given a NumPy typecode, return a string describing the type.
153 char* typecode_string(int typecode) {
154 static char* type_names[25] = {"bool", "byte", "unsigned byte",
155 "short", "unsigned short", "int",
156 "unsigned int", "long", "unsigned long",
157 "long long", "unsigned long long",
158 "float", "double", "long double",
159 "complex float", "complex double",
160 "complex long double", "object",
161 "string", "unicode", "void", "ntypes",
162 "notype", "char", "unknown"};
163 return typecode < 24 ? type_names[typecode] : type_names[24];
166 /* Make sure input has correct numpy type. Allow character and byte
167 * to match. Also allow int and long to match. This is deprecated.
168 * You should use PyArray_EquivTypenums() instead.
170 int type_match(int actual_type, int desired_type) {
171 return PyArray_EquivTypenums(actual_type, desired_type);
175 /**********************************************************************/
177 %fragment("NumPy_Object_to_Array", "header",
178 fragment="NumPy_Backward_Compatibility",
179 fragment="NumPy_Macros",
180 fragment="NumPy_Utilities")
182 /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
183 * legal. If not, set the python error string appropriately and
186 PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode)
188 PyArrayObject* ary = NULL;
189 if (is_array(input) && (typecode == NPY_NOTYPE ||
190 PyArray_EquivTypenums(array_type(input), typecode)))
192 ary = (PyArrayObject*) input;
194 else if is_array(input)
196 char* desired_type = typecode_string(typecode);
197 char* actual_type = typecode_string(array_type(input));
198 PyErr_Format(PyExc_TypeError,
199 "Array of type '%s' required. Array of type '%s' given",
200 desired_type, actual_type);
205 char * desired_type = typecode_string(typecode);
206 char * actual_type = pytype_string(input);
207 PyErr_Format(PyExc_TypeError,
208 "Array of type '%s' required. A '%s' was given",
209 desired_type, actual_type);
215 /* Convert the given PyObject to a NumPy array with the given
216 * typecode. On success, return a valid PyArrayObject* with the
217 * correct type. On failure, the python error string will be set and
218 * the routine returns NULL.
220 PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode,
223 PyArrayObject* ary = NULL;
225 if (is_array(input) && (typecode == NPY_NOTYPE ||
226 PyArray_EquivTypenums(array_type(input),typecode)))
228 ary = (PyArrayObject*) input;
233 py_obj = PyArray_FromObject(input, typecode, 0, 0);
234 /* If NULL, PyArray_FromObject will have set python error value.*/
235 ary = (PyArrayObject*) py_obj;
241 /* Given a PyArrayObject, check to see if it is contiguous. If so,
242 * return the input pointer and flag it as not a new object. If it is
243 * not contiguous, create a new PyArrayObject using the original data,
244 * flag it as a new object and return the pointer.
246 PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object,
247 int min_dims, int max_dims)
249 PyArrayObject* result;
250 if (array_is_contiguous(ary))
257 result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
266 /* Convert a given PyObject to a contiguous PyArrayObject of the
267 * specified type. If the input object is not a contiguous
268 * PyArrayObject, a new one will be created and the new object flag
271 PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
278 PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
282 ary2 = make_contiguous(ary1, &is_new2, 0, 0);
283 if ( is_new1 && is_new2)
289 *is_new_object = is_new1 || is_new2;
294 /**********************************************************************/
296 %fragment("NumPy_Array_Requirements", "header",
297 fragment="NumPy_Backward_Compatibility",
298 fragment="NumPy_Macros")
300 /* Test whether a python object is contiguous. If array is
301 * contiguous, return 1. Otherwise, set the python error string and
304 int require_contiguous(PyArrayObject* ary)
307 if (!array_is_contiguous(ary))
309 PyErr_SetString(PyExc_TypeError,
310 "Array must be contiguous. A non-contiguous array was given");
316 /* Require that a numpy array is not byte-swapped. If the array is
317 * not byte-swapped, return 1. Otherwise, set the python error string
320 int require_native(PyArrayObject* ary)
323 if (!array_is_native(ary))
325 PyErr_SetString(PyExc_TypeError,
326 "Array must have native byteorder. "
327 "A byte-swapped array was given");
333 /* Require the given PyArrayObject to have a specified number of
334 * dimensions. If the array has the specified number of dimensions,
335 * return 1. Otherwise, set the python error string and return 0.
337 int require_dimensions(PyArrayObject* ary, int exact_dimensions)
340 if (array_numdims(ary) != exact_dimensions)
342 PyErr_Format(PyExc_TypeError,
343 "Array must have %d dimensions. Given array has %d dimensions",
344 exact_dimensions, array_numdims(ary));
350 /* Require the given PyArrayObject to have one of a list of specified
351 * number of dimensions. If the array has one of the specified number
352 * of dimensions, return 1. Otherwise, set the python error string
355 int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n)
359 char dims_str[255] = "";
361 for (i = 0; i < n && !success; i++)
363 if (array_numdims(ary) == exact_dimensions[i])
370 for (i = 0; i < n-1; i++)
372 sprintf(s, "%d, ", exact_dimensions[i]);
375 sprintf(s, " or %d", exact_dimensions[n-1]);
377 PyErr_Format(PyExc_TypeError,
378 "Array must have %s dimensions. Given array has %d dimensions",
379 dims_str, array_numdims(ary));
384 /* Require the given PyArrayObject to have a specified shape. If the
385 * array has the specified shape, return 1. Otherwise, set the python
386 * error string and return 0.
388 int require_size(PyArrayObject* ary, npy_intp* size, int n)
393 char desired_dims[255] = "[";
395 char actual_dims[255] = "[";
398 if (size[i] != -1 && size[i] != array_size(ary,i))
405 for (i = 0; i < n; i++)
413 sprintf(s, "%ld,", (long int)size[i]);
415 strcat(desired_dims,s);
417 len = strlen(desired_dims);
418 desired_dims[len-1] = ']';
419 for (i = 0; i < n; i++)
421 sprintf(s, "%ld,", (long int)array_size(ary,i));
422 strcat(actual_dims,s);
424 len = strlen(actual_dims);
425 actual_dims[len-1] = ']';
426 PyErr_Format(PyExc_TypeError,
427 "Array must have shape of %s. Given array has shape of %s",
428 desired_dims, actual_dims);
433 /* Require the given PyArrayObject to to be FORTRAN ordered. If the
434 * the PyArrayObject is already FORTRAN ordered, do nothing. Else,
435 * set the FORTRAN ordering flag and recompute the strides.
437 int require_fortran(PyArrayObject* ary)
440 int nd = array_numdims(ary);
442 if (array_is_fortran(ary)) return success;
443 /* Set the FORTRAN ordered flag */
444 ary->flags = NPY_FARRAY;
445 /* Recompute the strides */
446 ary->strides[0] = ary->strides[nd-1];
447 for (i=1; i < nd; ++i)
448 ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1);
453 /* Combine all NumPy fragments into one for convenience */
454 %fragment("NumPy_Fragments", "header",
455 fragment="NumPy_Backward_Compatibility",
456 fragment="NumPy_Macros",
457 fragment="NumPy_Utilities",
458 fragment="NumPy_Object_to_Array",
459 fragment="NumPy_Array_Requirements") { }
461 /* End John Hunter translation (with modifications by Bill Spotz)
464 /* %numpy_typemaps() macro
466 * This macro defines a family of 41 typemaps that allow C arguments
469 * (DATA_TYPE IN_ARRAY1[ANY])
470 * (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
471 * (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
473 * (DATA_TYPE IN_ARRAY2[ANY][ANY])
474 * (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
475 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
476 * (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
477 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
479 * (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
480 * (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
481 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
482 * (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
483 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
485 * (DATA_TYPE INPLACE_ARRAY1[ANY])
486 * (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
487 * (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
489 * (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
490 * (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
491 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
492 * (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
493 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
495 * (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
496 * (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
497 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
498 * (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
499 * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
501 * (DATA_TYPE ARGOUT_ARRAY1[ANY])
502 * (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
503 * (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
505 * (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
507 * (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
509 * (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
510 * (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
512 * (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
513 * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
514 * (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
515 * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
517 * (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
518 * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
519 * (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
520 * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
522 * where "DATA_TYPE" is any type supported by the NumPy module, and
523 * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
524 * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
525 * that the "FARRAY" typemaps expect FORTRAN ordering of
526 * multidimensional arrays. In python, the dimensions will not need
527 * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
528 * typemaps). The IN_ARRAYs can be a numpy array or any sequence that
529 * can be converted to a numpy array of the specified type. The
530 * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The
531 * ARGOUT_ARRAYs will be returned as new numpy arrays of the
534 * These typemaps can be applied to existing functions using the
535 * %apply directive. For example:
537 * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
538 * double prod(double* series, int length);
540 * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
541 * {(int rows, int cols, double* matrix )};
542 * void floor(int rows, int cols, double* matrix, double f);
544 * %apply (double IN_ARRAY3[ANY][ANY][ANY])
545 * {(double tensor[2][2][2] )};
546 * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
547 * {(double low[2][2][2] )};
548 * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
549 * {(double upp[2][2][2] )};
550 * void luSplit(double tensor[2][2][2],
551 * double low[2][2][2],
552 * double upp[2][2][2] );
556 * double prod(double* IN_ARRAY1, int DIM1);
558 * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
560 * void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
561 * double ARGOUT_ARRAY3[ANY][ANY][ANY],
562 * double ARGOUT_ARRAY3[ANY][ANY][ANY]);
565 %define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
567 /************************/
568 /* Input Array Typemaps */
569 /************************/
571 /* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
573 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
574 fragment="NumPy_Macros")
575 (DATA_TYPE IN_ARRAY1[ANY])
577 $1 = is_array($input) || PySequence_Check($input);
580 fragment="NumPy_Fragments")
581 (DATA_TYPE IN_ARRAY1[ANY])
582 (PyArrayObject* array=NULL, int is_new_object=0)
584 npy_intp size[1] = { $1_dim0 };
585 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
587 if (!array || !require_dimensions(array, 1) ||
588 !require_size(array, size, 1)) SWIG_fail;
589 $1 = ($1_ltype) array_data(array);
592 (DATA_TYPE IN_ARRAY1[ANY])
594 if (is_new_object$argnum && array$argnum)
595 { Py_DECREF(array$argnum); }
598 /* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
600 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
601 fragment="NumPy_Macros")
602 (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
604 $1 = is_array($input) || PySequence_Check($input);
607 fragment="NumPy_Fragments")
608 (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
609 (PyArrayObject* array=NULL, int is_new_object=0)
611 npy_intp size[1] = { -1 };
612 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
614 if (!array || !require_dimensions(array, 1) ||
615 !require_size(array, size, 1)) SWIG_fail;
616 $1 = (DATA_TYPE*) array_data(array);
617 $2 = (DIM_TYPE) array_size(array,0);
620 (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
622 if (is_new_object$argnum && array$argnum)
623 { Py_DECREF(array$argnum); }
626 /* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
628 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
629 fragment="NumPy_Macros")
630 (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
632 $1 = is_array($input) || PySequence_Check($input);
635 fragment="NumPy_Fragments")
636 (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
637 (PyArrayObject* array=NULL, int is_new_object=0)
639 npy_intp size[1] = {-1};
640 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
642 if (!array || !require_dimensions(array, 1) ||
643 !require_size(array, size, 1)) SWIG_fail;
644 $1 = (DIM_TYPE) array_size(array,0);
645 $2 = (DATA_TYPE*) array_data(array);
648 (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
650 if (is_new_object$argnum && array$argnum)
651 { Py_DECREF(array$argnum); }
654 /* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
656 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
657 fragment="NumPy_Macros")
658 (DATA_TYPE IN_ARRAY2[ANY][ANY])
660 $1 = is_array($input) || PySequence_Check($input);
663 fragment="NumPy_Fragments")
664 (DATA_TYPE IN_ARRAY2[ANY][ANY])
665 (PyArrayObject* array=NULL, int is_new_object=0)
667 npy_intp size[2] = { $1_dim0, $1_dim1 };
668 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
670 if (!array || !require_dimensions(array, 2) ||
671 !require_size(array, size, 2)) SWIG_fail;
672 $1 = ($1_ltype) array_data(array);
675 (DATA_TYPE IN_ARRAY2[ANY][ANY])
677 if (is_new_object$argnum && array$argnum)
678 { Py_DECREF(array$argnum); }
681 /* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
683 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
684 fragment="NumPy_Macros")
685 (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
687 $1 = is_array($input) || PySequence_Check($input);
690 fragment="NumPy_Fragments")
691 (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
692 (PyArrayObject* array=NULL, int is_new_object=0)
694 npy_intp size[2] = { -1, -1 };
695 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
697 if (!array || !require_dimensions(array, 2) ||
698 !require_size(array, size, 2)) SWIG_fail;
699 $1 = (DATA_TYPE*) array_data(array);
700 $2 = (DIM_TYPE) array_size(array,0);
701 $3 = (DIM_TYPE) array_size(array,1);
704 (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
706 if (is_new_object$argnum && array$argnum)
707 { Py_DECREF(array$argnum); }
710 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
712 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
713 fragment="NumPy_Macros")
714 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
716 $1 = is_array($input) || PySequence_Check($input);
719 fragment="NumPy_Fragments")
720 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
721 (PyArrayObject* array=NULL, int is_new_object=0)
723 npy_intp size[2] = { -1, -1 };
724 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
726 if (!array || !require_dimensions(array, 2) ||
727 !require_size(array, size, 2)) SWIG_fail;
728 $1 = (DIM_TYPE) array_size(array,0);
729 $2 = (DIM_TYPE) array_size(array,1);
730 $3 = (DATA_TYPE*) array_data(array);
733 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
735 if (is_new_object$argnum && array$argnum)
736 { Py_DECREF(array$argnum); }
739 /* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
741 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
742 fragment="NumPy_Macros")
743 (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
745 $1 = is_array($input) || PySequence_Check($input);
748 fragment="NumPy_Fragments")
749 (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
750 (PyArrayObject* array=NULL, int is_new_object=0)
752 npy_intp size[2] = { -1, -1 };
753 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
755 if (!array || !require_dimensions(array, 2) ||
756 !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
757 $1 = (DATA_TYPE*) array_data(array);
758 $2 = (DIM_TYPE) array_size(array,0);
759 $3 = (DIM_TYPE) array_size(array,1);
762 (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
764 if (is_new_object$argnum && array$argnum)
765 { Py_DECREF(array$argnum); }
768 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
770 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
771 fragment="NumPy_Macros")
772 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
774 $1 = is_array($input) || PySequence_Check($input);
777 fragment="NumPy_Fragments")
778 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
779 (PyArrayObject* array=NULL, int is_new_object=0)
781 npy_intp size[2] = { -1, -1 };
782 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
784 if (!array || !require_dimensions(array, 2) ||
785 !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
786 $1 = (DIM_TYPE) array_size(array,0);
787 $2 = (DIM_TYPE) array_size(array,1);
788 $3 = (DATA_TYPE*) array_data(array);
791 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
793 if (is_new_object$argnum && array$argnum)
794 { Py_DECREF(array$argnum); }
797 /* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
799 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
800 fragment="NumPy_Macros")
801 (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
803 $1 = is_array($input) || PySequence_Check($input);
806 fragment="NumPy_Fragments")
807 (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
808 (PyArrayObject* array=NULL, int is_new_object=0)
810 npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
811 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
813 if (!array || !require_dimensions(array, 3) ||
814 !require_size(array, size, 3)) SWIG_fail;
815 $1 = ($1_ltype) array_data(array);
818 (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
820 if (is_new_object$argnum && array$argnum)
821 { Py_DECREF(array$argnum); }
824 /* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
827 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
828 fragment="NumPy_Macros")
829 (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
831 $1 = is_array($input) || PySequence_Check($input);
834 fragment="NumPy_Fragments")
835 (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
836 (PyArrayObject* array=NULL, int is_new_object=0)
838 npy_intp size[3] = { -1, -1, -1 };
839 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
841 if (!array || !require_dimensions(array, 3) ||
842 !require_size(array, size, 3)) SWIG_fail;
843 $1 = (DATA_TYPE*) array_data(array);
844 $2 = (DIM_TYPE) array_size(array,0);
845 $3 = (DIM_TYPE) array_size(array,1);
846 $4 = (DIM_TYPE) array_size(array,2);
849 (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
851 if (is_new_object$argnum && array$argnum)
852 { Py_DECREF(array$argnum); }
855 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
856 * DATA_TYPE* IN_ARRAY3)
858 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
859 fragment="NumPy_Macros")
860 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
862 $1 = is_array($input) || PySequence_Check($input);
865 fragment="NumPy_Fragments")
866 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
867 (PyArrayObject* array=NULL, int is_new_object=0)
869 npy_intp size[3] = { -1, -1, -1 };
870 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
872 if (!array || !require_dimensions(array, 3) ||
873 !require_size(array, size, 3)) SWIG_fail;
874 $1 = (DIM_TYPE) array_size(array,0);
875 $2 = (DIM_TYPE) array_size(array,1);
876 $3 = (DIM_TYPE) array_size(array,2);
877 $4 = (DATA_TYPE*) array_data(array);
880 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
882 if (is_new_object$argnum && array$argnum)
883 { Py_DECREF(array$argnum); }
886 /* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
889 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
890 fragment="NumPy_Macros")
891 (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
893 $1 = is_array($input) || PySequence_Check($input);
896 fragment="NumPy_Fragments")
897 (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
898 (PyArrayObject* array=NULL, int is_new_object=0)
900 npy_intp size[3] = { -1, -1, -1 };
901 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
903 if (!array || !require_dimensions(array, 3) ||
904 !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
905 $1 = (DATA_TYPE*) array_data(array);
906 $2 = (DIM_TYPE) array_size(array,0);
907 $3 = (DIM_TYPE) array_size(array,1);
908 $4 = (DIM_TYPE) array_size(array,2);
911 (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
913 if (is_new_object$argnum && array$argnum)
914 { Py_DECREF(array$argnum); }
917 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
918 * DATA_TYPE* IN_FARRAY3)
920 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
921 fragment="NumPy_Macros")
922 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
924 $1 = is_array($input) || PySequence_Check($input);
927 fragment="NumPy_Fragments")
928 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
929 (PyArrayObject* array=NULL, int is_new_object=0)
931 npy_intp size[3] = { -1, -1, -1 };
932 array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
934 if (!array || !require_dimensions(array, 3) ||
935 !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
936 $1 = (DIM_TYPE) array_size(array,0);
937 $2 = (DIM_TYPE) array_size(array,1);
938 $3 = (DIM_TYPE) array_size(array,2);
939 $4 = (DATA_TYPE*) array_data(array);
942 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
944 if (is_new_object$argnum && array$argnum)
945 { Py_DECREF(array$argnum); }
948 /***************************/
949 /* In-Place Array Typemaps */
950 /***************************/
952 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
954 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
955 fragment="NumPy_Macros")
956 (DATA_TYPE INPLACE_ARRAY1[ANY])
958 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
962 fragment="NumPy_Fragments")
963 (DATA_TYPE INPLACE_ARRAY1[ANY])
964 (PyArrayObject* array=NULL)
966 npy_intp size[1] = { $1_dim0 };
967 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
968 if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
969 !require_contiguous(array) || !require_native(array)) SWIG_fail;
970 $1 = ($1_ltype) array_data(array);
973 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
975 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
976 fragment="NumPy_Macros")
977 (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
979 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
983 fragment="NumPy_Fragments")
984 (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
985 (PyArrayObject* array=NULL, int i=1)
987 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
988 if (!array || !require_dimensions(array,1) || !require_contiguous(array)
989 || !require_native(array)) SWIG_fail;
990 $1 = (DATA_TYPE*) array_data(array);
992 for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
995 /* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
997 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
998 fragment="NumPy_Macros")
999 (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1001 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1005 fragment="NumPy_Fragments")
1006 (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
1007 (PyArrayObject* array=NULL, int i=0)
1009 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1010 if (!array || !require_dimensions(array,1) || !require_contiguous(array)
1011 || !require_native(array)) SWIG_fail;
1013 for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
1014 $2 = (DATA_TYPE*) array_data(array);
1017 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1019 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1020 fragment="NumPy_Macros")
1021 (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1023 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1027 fragment="NumPy_Fragments")
1028 (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
1029 (PyArrayObject* array=NULL)
1031 npy_intp size[2] = { $1_dim0, $1_dim1 };
1032 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1033 if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
1034 !require_contiguous(array) || !require_native(array)) SWIG_fail;
1035 $1 = ($1_ltype) array_data(array);
1038 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1040 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1041 fragment="NumPy_Macros")
1042 (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1044 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1048 fragment="NumPy_Fragments")
1049 (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1050 (PyArrayObject* array=NULL)
1052 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1053 if (!array || !require_dimensions(array,2) || !require_contiguous(array)
1054 || !require_native(array)) SWIG_fail;
1055 $1 = (DATA_TYPE*) array_data(array);
1056 $2 = (DIM_TYPE) array_size(array,0);
1057 $3 = (DIM_TYPE) array_size(array,1);
1060 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1062 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1063 fragment="NumPy_Macros")
1064 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1066 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1070 fragment="NumPy_Fragments")
1071 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
1072 (PyArrayObject* array=NULL)
1074 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1075 if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
1076 !require_native(array)) SWIG_fail;
1077 $1 = (DIM_TYPE) array_size(array,0);
1078 $2 = (DIM_TYPE) array_size(array,1);
1079 $3 = (DATA_TYPE*) array_data(array);
1082 /* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1084 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1085 fragment="NumPy_Macros")
1086 (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1088 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1092 fragment="NumPy_Fragments")
1093 (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
1094 (PyArrayObject* array=NULL)
1096 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1097 if (!array || !require_dimensions(array,2) || !require_contiguous(array)
1098 || !require_native(array) || !require_fortran(array)) SWIG_fail;
1099 $1 = (DATA_TYPE*) array_data(array);
1100 $2 = (DIM_TYPE) array_size(array,0);
1101 $3 = (DIM_TYPE) array_size(array,1);
1104 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1106 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1107 fragment="NumPy_Macros")
1108 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1110 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1114 fragment="NumPy_Fragments")
1115 (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
1116 (PyArrayObject* array=NULL)
1118 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1119 if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
1120 !require_native(array) || !require_fortran(array)) SWIG_fail;
1121 $1 = (DIM_TYPE) array_size(array,0);
1122 $2 = (DIM_TYPE) array_size(array,1);
1123 $3 = (DATA_TYPE*) array_data(array);
1126 /* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1128 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1129 fragment="NumPy_Macros")
1130 (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1132 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1136 fragment="NumPy_Fragments")
1137 (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
1138 (PyArrayObject* array=NULL)
1140 npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
1141 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1142 if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
1143 !require_contiguous(array) || !require_native(array)) SWIG_fail;
1144 $1 = ($1_ltype) array_data(array);
1147 /* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1150 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1151 fragment="NumPy_Macros")
1152 (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1154 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1158 fragment="NumPy_Fragments")
1159 (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1160 (PyArrayObject* array=NULL)
1162 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1163 if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
1164 !require_native(array)) SWIG_fail;
1165 $1 = (DATA_TYPE*) array_data(array);
1166 $2 = (DIM_TYPE) array_size(array,0);
1167 $3 = (DIM_TYPE) array_size(array,1);
1168 $4 = (DIM_TYPE) array_size(array,2);
1171 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1172 * DATA_TYPE* INPLACE_ARRAY3)
1174 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1175 fragment="NumPy_Macros")
1176 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
1178 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1182 fragment="NumPy_Fragments")
1183 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
1184 (PyArrayObject* array=NULL)
1186 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1187 if (!array || !require_dimensions(array,3) || !require_contiguous(array)
1188 || !require_native(array)) SWIG_fail;
1189 $1 = (DIM_TYPE) array_size(array,0);
1190 $2 = (DIM_TYPE) array_size(array,1);
1191 $3 = (DIM_TYPE) array_size(array,2);
1192 $4 = (DATA_TYPE*) array_data(array);
1195 /* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
1198 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1199 fragment="NumPy_Macros")
1200 (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1202 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1206 fragment="NumPy_Fragments")
1207 (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
1208 (PyArrayObject* array=NULL)
1210 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1211 if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
1212 !require_native(array) || !require_fortran(array)) SWIG_fail;
1213 $1 = (DATA_TYPE*) array_data(array);
1214 $2 = (DIM_TYPE) array_size(array,0);
1215 $3 = (DIM_TYPE) array_size(array,1);
1216 $4 = (DIM_TYPE) array_size(array,2);
1219 /* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
1220 * DATA_TYPE* INPLACE_FARRAY3)
1222 %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
1223 fragment="NumPy_Macros")
1224 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
1226 $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
1230 fragment="NumPy_Fragments")
1231 (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
1232 (PyArrayObject* array=NULL)
1234 array = obj_to_array_no_conversion($input, DATA_TYPECODE);
1235 if (!array || !require_dimensions(array,3) || !require_contiguous(array)
1236 || !require_native(array) || !require_fortran(array)) SWIG_fail;
1237 $1 = (DIM_TYPE) array_size(array,0);
1238 $2 = (DIM_TYPE) array_size(array,1);
1239 $3 = (DIM_TYPE) array_size(array,2);
1240 $4 = (DATA_TYPE*) array_data(array);
1243 /*************************/
1244 /* Argout Array Typemaps */
1245 /*************************/
1247 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
1249 %typemap(in,numinputs=0,
1250 fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1251 (DATA_TYPE ARGOUT_ARRAY1[ANY])
1252 (PyObject * array = NULL)
1254 npy_intp dims[1] = { $1_dim0 };
1255 array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1256 if (!array) SWIG_fail;
1257 $1 = ($1_ltype) array_data(array);
1260 (DATA_TYPE ARGOUT_ARRAY1[ANY])
1262 $result = SWIG_Python_AppendOutput($result,array$argnum);
1265 /* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1267 %typemap(in,numinputs=1,
1268 fragment="NumPy_Fragments")
1269 (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1270 (PyObject * array = NULL)
1273 if (!PyInt_Check($input))
1275 char* typestring = pytype_string($input);
1276 PyErr_Format(PyExc_TypeError,
1277 "Int dimension expected. '%s' given.",
1281 $2 = (DIM_TYPE) PyInt_AsLong($input);
1282 dims[0] = (npy_intp) $2;
1283 array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1284 if (!array) SWIG_fail;
1285 $1 = (DATA_TYPE*) array_data(array);
1288 (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
1290 $result = SWIG_Python_AppendOutput($result,array$argnum);
1293 /* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
1295 %typemap(in,numinputs=1,
1296 fragment="NumPy_Fragments")
1297 (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
1298 (PyObject * array = NULL)
1301 if (!PyInt_Check($input))
1303 char* typestring = pytype_string($input);
1304 PyErr_Format(PyExc_TypeError,
1305 "Int dimension expected. '%s' given.",
1309 $1 = (DIM_TYPE) PyInt_AsLong($input);
1310 dims[0] = (npy_intp) $1;
1311 array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
1312 if (!array) SWIG_fail;
1313 $2 = (DATA_TYPE*) array_data(array);
1316 (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
1318 $result = SWIG_Python_AppendOutput($result,array$argnum);
1321 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
1323 %typemap(in,numinputs=0,
1324 fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1325 (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
1326 (PyObject * array = NULL)
1328 npy_intp dims[2] = { $1_dim0, $1_dim1 };
1329 array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
1330 if (!array) SWIG_fail;
1331 $1 = ($1_ltype) array_data(array);
1334 (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
1336 $result = SWIG_Python_AppendOutput($result,array$argnum);
1339 /* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
1341 %typemap(in,numinputs=0,
1342 fragment="NumPy_Backward_Compatibility,NumPy_Macros")
1343 (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
1344 (PyObject * array = NULL)
1346 npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
1347 array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
1348 if (!array) SWIG_fail;
1349 $1 = ($1_ltype) array_data(array);
1352 (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
1354 $result = SWIG_Python_AppendOutput($result,array$argnum);
1357 /*****************************/
1358 /* Argoutview Array Typemaps */
1359 /*****************************/
1361 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
1363 %typemap(in,numinputs=0)
1364 (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 )
1365 (DATA_TYPE* data_temp , DIM_TYPE dim_temp)
1371 fragment="NumPy_Backward_Compatibility")
1372 (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
1374 npy_intp dims[1] = { *$2 };
1375 PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
1376 if (!array) SWIG_fail;
1377 $result = SWIG_Python_AppendOutput($result,array);
1380 /* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
1382 %typemap(in,numinputs=0)
1383 (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1)
1384 (DIM_TYPE dim_temp, DATA_TYPE* data_temp )
1390 fragment="NumPy_Backward_Compatibility")
1391 (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
1393 npy_intp dims[1] = { *$1 };
1394 PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
1395 if (!array) SWIG_fail;
1396 $result = SWIG_Python_AppendOutput($result,array);
1399 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1401 %typemap(in,numinputs=0)
1402 (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
1403 (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
1410 fragment="NumPy_Backward_Compatibility")
1411 (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1413 npy_intp dims[2] = { *$2, *$3 };
1414 PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
1415 if (!array) SWIG_fail;
1416 $result = SWIG_Python_AppendOutput($result,array);
1419 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
1421 %typemap(in,numinputs=0)
1422 (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2)
1423 (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp )
1430 fragment="NumPy_Backward_Compatibility")
1431 (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
1433 npy_intp dims[2] = { *$1, *$2 };
1434 PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
1435 if (!array) SWIG_fail;
1436 $result = SWIG_Python_AppendOutput($result,array);
1439 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1441 %typemap(in,numinputs=0)
1442 (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 )
1443 (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp)
1450 fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1451 (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
1453 npy_intp dims[2] = { *$2, *$3 };
1454 PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
1455 PyArrayObject * array = (PyArrayObject*) obj;
1456 if (!array || !require_fortran(array)) SWIG_fail;
1457 $result = SWIG_Python_AppendOutput($result,obj);
1460 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
1462 %typemap(in,numinputs=0)
1463 (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2)
1464 (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp )
1471 fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1472 (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
1474 npy_intp dims[2] = { *$1, *$2 };
1475 PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
1476 PyArrayObject * array = (PyArrayObject*) obj;
1477 if (!array || !require_fortran(array)) SWIG_fail;
1478 $result = SWIG_Python_AppendOutput($result,obj);
1481 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
1484 %typemap(in,numinputs=0)
1485 (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
1486 (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
1494 fragment="NumPy_Backward_Compatibility")
1495 (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
1497 npy_intp dims[3] = { *$2, *$3, *$4 };
1498 PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
1499 if (!array) SWIG_fail;
1500 $result = SWIG_Python_AppendOutput($result,array);
1503 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
1504 DATA_TYPE** ARGOUTVIEW_ARRAY3)
1506 %typemap(in,numinputs=0)
1507 (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
1508 (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
1516 fragment="NumPy_Backward_Compatibility")
1517 (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
1519 npy_intp dims[3] = { *$1, *$2, *$3 };
1520 PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
1521 if (!array) SWIG_fail;
1522 $result = SWIG_Python_AppendOutput($result,array);
1525 /* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
1528 %typemap(in,numinputs=0)
1529 (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
1530 (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
1538 fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1539 (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
1541 npy_intp dims[3] = { *$2, *$3, *$4 };
1542 PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
1543 PyArrayObject * array = (PyArrayObject*) obj;
1544 if (!array || require_fortran(array)) SWIG_fail;
1545 $result = SWIG_Python_AppendOutput($result,obj);
1548 /* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
1549 DATA_TYPE** ARGOUTVIEW_FARRAY3)
1551 %typemap(in,numinputs=0)
1552 (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
1553 (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
1561 fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
1562 (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
1564 npy_intp dims[3] = { *$1, *$2, *$3 };
1565 PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
1566 PyArrayObject * array = (PyArrayObject*) obj;
1567 if (!array || require_fortran(array)) SWIG_fail;
1568 $result = SWIG_Python_AppendOutput($result,obj);
1571 %enddef /* %numpy_typemaps() macro */
1572 /* *************************************************************** */
1574 /* Concrete instances of the %numpy_typemaps() macro: Each invocation
1575 * below applies all of the typemaps above to the specified data type.
1577 %numpy_typemaps(signed char , NPY_BYTE , int)
1578 %numpy_typemaps(unsigned char , NPY_UBYTE , int)
1579 %numpy_typemaps(short , NPY_SHORT , int)
1580 %numpy_typemaps(unsigned short , NPY_USHORT , int)
1581 %numpy_typemaps(int , NPY_INT , int)
1582 %numpy_typemaps(unsigned int , NPY_UINT , int)
1583 %numpy_typemaps(long , NPY_LONG , int)
1584 %numpy_typemaps(unsigned long , NPY_ULONG , int)
1585 %numpy_typemaps(long long , NPY_LONGLONG , int)
1586 %numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
1587 %numpy_typemaps(float , NPY_FLOAT , int)
1588 %numpy_typemaps(double , NPY_DOUBLE , int)
1590 /* ***************************************************************
1591 * The follow macro expansion does not work, because C++ bool is 4
1592 * bytes and NPY_BOOL is 1 byte
1594 * %numpy_typemaps(bool, NPY_BOOL, int)
1597 /* ***************************************************************
1598 * On my Mac, I get the following warning for this macro expansion:
1599 * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
1601 * %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
1604 /* ***************************************************************
1605 * Swig complains about a syntax error for the following macro
1608 * %numpy_typemaps(complex float, NPY_CFLOAT , int)
1610 * %numpy_typemaps(complex double, NPY_CDOUBLE, int)
1612 * %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
1615 #endif /* SWIGPYTHON */